From pub@bednarz.ch Thu Jun 9 19:50:18 2011 Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 3B5EEB5DBBD for ; Thu, 9 Jun 2011 16:50:18 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 47122-05 for ; Thu, 9 Jun 2011 19:50:11 +0000 (UTC) X-Greylist: delayed 00:31:41.879209 by SQLgrey-1.7.6 Received: from pluto.tkmb.ch (pluto.tkmb.ch [80.74.155.185]) by mail.postgresql.org (Postfix) with ESMTP id 972A7B5D80A for ; Thu, 9 Jun 2011 16:50:10 -0300 (ADT) Received: from [172.16.63.102] [81.221.8.117] by mail.tkmb.ch with ESMTP (SMTPD-11.03) id 98200000029a031a; Thu, 9 Jun 2011 21:18:17 +0200 Message-ID: <4DF11C79.2000505@bednarz.ch> Date: Thu, 09 Jun 2011 21:18:17 +0200 From: Thomas Bednarz User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: calling pg_dump from perl Content-Type: multipart/alternative; boundary="------------050003050805070201000706" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201106/48 X-Sequence-Number: 37674 This is a multi-part message in MIME format. --------------050003050805070201000706 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Hi everyone, I try to do scheduled backups with a perl script on a windose box. For=20 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 =3D localtime(); my $backupfile =3D sprintf("%s/PostgresDBBackup_%s_%s_%04s%02s%02s%02s%02= s%02s.bak", $BackupPath, $hostname, $DBName, $tm->year+1900, $tm->mon+1, $tm->mday,= $tm->hour, $tm->min, $tm->sec); my $backupargs =3D sprintf("-f %s -F p --clean -U postgres -h localhost %= s", $backupfile, $DBName); my @args =3D ($pgbackup, $backupargs); print "COMMAND: ".$pgbackup." ".$backupargs."\n"; my $status =3D system(@args); The line starting with 'print "COMMAND: " ' outputs the command to the c= onsole. It looks as follows: COMMAND: E:\PostgreSQL\8.4SS\bin/pg_dump.exe -f=20 //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.=20 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=20 when passed to the system() command, even though in the perl debugger=20 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=20 //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 =BBTB=AB=20 fehlgeschlagen: fe_sendauth: no password supplied 256 The interesting thing is, that it asks for a password for a database=20 named "TB". Only god knows where that comes from! The name of my=20 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=20 WITHOUT asking for a password, which means it finds it in the password fi= le. Does anybody see what the heck I am doing wrong here? Many thanks for your help! Thomas --------------050003050805070201000706 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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


--------------050003050805070201000706-- From greg@turnstep.com Thu Jun 9 20:16:33 2011 Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id C8E08B5DBD3 for ; Thu, 9 Jun 2011 17:16:33 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 64133-07 for ; Thu, 9 Jun 2011 20:16:26 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from zql.com (zql.com [206.222.31.58]) by mail.postgresql.org (Postfix) with ESMTP id 6B930B5DBBD for ; Thu, 9 Jun 2011 17:16:26 -0300 (ADT) Received: from localhost ([127.0.0.1]) by zql.com with smtp (Exim 4.68) (envelope-from ) id 1QUleS-00061L-6Q; Thu, 09 Jun 2011 16:16:24 -0400 From: "Greg Sabino Mullane" To: pgsql-admin@postgresql.org Cc: pub@bednarz.ch CC: pub@bednarz.ch Subject: Re: calling pg_dump from perl X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 X-Request-PGP: http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 In-Reply-To: <4DF11C79.2000505@bednarz.ch> Date: Thu, 9 Jun 2011 20:16:24 -0000 X-Mailer: JoyMail 2.4.0 Message-ID: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/49 X-Sequence-Number: 37675 -----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----- From pub@bednarz.ch Fri Jun 10 05:14:08 2011 Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E8B37B5DBBE for ; Fri, 10 Jun 2011 02:14:08 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 00593-01 for ; Fri, 10 Jun 2011 05:14:01 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from pluto.tkmb.ch (pluto.tkmb.ch [80.74.155.185]) by mail.postgresql.org (Postfix) with ESMTP id 270D8B5D94C for ; Fri, 10 Jun 2011 02:14:00 -0300 (ADT) Received: from [172.16.63.102] [81.221.8.117] by mail.tkmb.ch with ESMTP (SMTPD-11.03) id a46c000003bd046d; Fri, 10 Jun 2011 07:13:07 +0200 Message-ID: <4DF1A811.2090202@bednarz.ch> Date: Fri, 10 Jun 2011 07:13:53 +0200 From: Thomas Bednarz User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: calling pg_dump from perl References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/51 X-Sequence-Number: 37677 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----- > > >