pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
calling pg_dump from perl
3+ messages / 2 participants
[nested] [flat]

* calling pg_dump from perl
@ 2011-06-09 19:18 Thomas Bednarz <pub@bednarz.ch>
  2011-06-09 20:16 ` Re: calling pg_dump from perl Greg Sabino Mullane <greg@turnstep.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Thomas Bednarz @ 2011-06-09 19:18 UTC (permalink / raw)
  To: pgsql-admin

Hi everyone,

I try to do scheduled backups with a perl script on a windose box. For 
some reason this does not work and I am to stupid to see the reason why. 
Maybe there is somebody out there who can help me.

Here is the relevant part of my perl script:

my $tm = localtime();
my $backupfile = sprintf("%s/PostgresDBBackup_%s_%s_%04s%02s%02s%02s%02s%02s.bak", $BackupPath, $hostname,
                          $DBName, $tm->year+1900, $tm->mon+1, $tm->mday, $tm->hour, $tm->min, $tm->sec);
my $backupargs = sprintf("-f %s -F p --clean -U postgres -h localhost %s", $backupfile, $DBName);
my @args = ($pgbackup, $backupargs);
print "COMMAND: ".$pgbackup." ".$backupargs."\n";
my $status = system(@args);



The line starting with 'print "COMMAND: " '  outputs the command to the console. It looks as follows:



COMMAND: E:\PostgreSQL\8.4SS\bin/pg_dump.exe -f 
//nas-tb/DBBackups/PostgresDBBackup_TB-WS_misdwh_20110609151147.bak -F p 
--clean -U postgres -h localhost misdwh

If I execute this command on a Windows 'Shell' it works like a charm. 
But when passed to the perl command system() it asks for a password!!! I 
guess that for whatever reason the command is not correctly formatted 
when passed to the system() command, even though in the perl debugger 
the values in the array @args look great!

The error message on the console looks as follows:


COMMAND: E:\PostgreSQL\8.4SS\bin/pg_dump.exe -f 
//nas-tb/DBBackups/PostgresDBBackup_TB-WS_misdwh_20110609151147.bak -F p 
--clean -U postgres -h localhost misdwh
Passwort:
pg_dump: [Archivierer (DB)] Verbindung zur Datenbank »TB« 
fehlgeschlagen: fe_sendauth: no password supplied
256

The interesting thing is, that it asks for a password for a database 
named "TB". Only god knows where that comes from! The name of my 
database is 'misdwh' and as can be seen on the command is passed as last 
parameter. When copy paste the command to a DOS box it works just fine 
WITHOUT asking for a password, which means it finds it in the password file.

Does anybody see what the heck I am doing wrong here?

Many thanks for your help!

Thomas

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: calling pg_dump from perl
  2011-06-09 19:18 calling pg_dump from perl Thomas Bednarz <pub@bednarz.ch>
@ 2011-06-09 20:16 ` Greg Sabino Mullane <greg@turnstep.com>
  2011-06-10 05:13   ` Re: calling pg_dump from perl Thomas Bednarz <pub@bednarz.ch>
  0 siblings, 1 reply; 3+ messages in thread

From: Greg Sabino Mullane @ 2011-06-09 20:16 UTC (permalink / raw)
  To: pgsql-admin; +Cc: pub@bednarz.ch


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160


> COMMAND: E:\PostgreSQL\8.4SS\bin/pg_dump.exe -f 
> //nas-tb/DBBackups/PostgresDBBackup_TB-WS_misdwh_20110609151147.bak -F p 
> --clean -U postgres -h localhost misdwh
...
> The interesting thing is, that it asks for a password for a database 
> named "TB". Only god knows where that comes from! The name of my 
> database is 'misdwh' and as can be seen on the command is passed as last 
> parameter.

I would guess that TB is coming from the underscore in the filename. 
Try quoting the entire argument to -f like so:

E:\PostgreSQL\8.4SS\bin/pg_dump.exe 
 -f "//nas-tb/DBBackups/PostgresDBBackup_TB-WS_misdwh_20110609151147.bak"
 -F p --clean -U postgres -h localhost misdwh

- -- 
Greg Sabino Mullane greg@turnstep.com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201106091615
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8

-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAk3xKfEACgkQvJuQZxSWSsgyVACfQhuu35ITUETQ9aGT0muPrGb+
fnsAnRrfEaMdBNcou9UVvln0EpxYfvHf
=SNZ6
-----END PGP SIGNATURE-----





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: calling pg_dump from perl
  2011-06-09 19:18 calling pg_dump from perl Thomas Bednarz <pub@bednarz.ch>
  2011-06-09 20:16 ` Re: calling pg_dump from perl Greg Sabino Mullane <greg@turnstep.com>
@ 2011-06-10 05:13   ` Thomas Bednarz <pub@bednarz.ch>
  0 siblings, 0 replies; 3+ messages in thread

From: Thomas Bednarz @ 2011-06-10 05:13 UTC (permalink / raw)
  To: pgsql-admin

Hi Greg,

Yeah, thanks a lot. Works perfect. The correct perl code is:

my $backupargs = sprintf("-f \"%s\" -F p --clean -U postgres -h 
localhost %s", $backupfile, $DBName);


Cheers
Thomas

Am 09.06.2011 22:16, schrieb Greg Sabino Mullane:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: RIPEMD160
>
>
>> COMMAND: E:\PostgreSQL\8.4SS\bin/pg_dump.exe -f
>> //nas-tb/DBBackups/PostgresDBBackup_TB-WS_misdwh_20110609151147.bak -F p
>> --clean -U postgres -h localhost misdwh
> ...
>> The interesting thing is, that it asks for a password for a database
>> named "TB". Only god knows where that comes from! The name of my
>> database is 'misdwh' and as can be seen on the command is passed as last
>> parameter.
> I would guess that TB is coming from the underscore in the filename.
> Try quoting the entire argument to -f like so:
>
> E:\PostgreSQL\8.4SS\bin/pg_dump.exe
>   -f "//nas-tb/DBBackups/PostgresDBBackup_TB-WS_misdwh_20110609151147.bak"
>   -F p --clean -U postgres -h localhost misdwh
>
> - -- 
> Greg Sabino Mullane greg@turnstep.com
> End Point Corporation http://www.endpoint.com/
> PGP Key: 0x14964AC8 201106091615
> http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
>
> -----BEGIN PGP SIGNATURE-----
>
> iEYEAREDAAYFAk3xKfEACgkQvJuQZxSWSsgyVACfQhuu35ITUETQ9aGT0muPrGb+
> fnsAnRrfEaMdBNcou9UVvln0EpxYfvHf
> =SNZ6
> -----END PGP SIGNATURE-----
>
>
>





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2011-06-10 05:13 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-06-09 19:18 calling pg_dump from perl Thomas Bednarz <pub@bednarz.ch>
2011-06-09 20:16 ` Greg Sabino Mullane <greg@turnstep.com>
2011-06-10 05:13   ` Thomas Bednarz <pub@bednarz.ch>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox