From: Thomas Bednarz <pub@bednarz.ch>
To: pgsql-admin@postgresql.org
Subject: calling pg_dump from perl
Date: Thu, 09 Jun 2011 21:18:17 +0200
Message-ID: <4DF11C79.2000505@bednarz.ch> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: pub@bednarz.ch
Subject: Re: calling pg_dump from perl
In-Reply-To: <4DF11C79.2000505@bednarz.ch>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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