pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
dumping a password-protected db from a perl script or a binary
4+ messages / 2 participants
[nested] [flat]

* dumping a password-protected db from a perl script or a binary
@ 2002-11-04 13:32 dima <_pppp@mail.ru>
  2002-11-04 15:12 ` Re: dumping a password-protected db from a perl script or a binary Artur Pietruk <arturp@plukwa.pdi.net>
  0 siblings, 1 reply; 4+ messages in thread

From: dima @ 2002-11-04 13:32 UTC (permalink / raw)
  To: pgsql-admin

How can i dump a password-protected database using perl (DBI or pg) or C 
(using libpq)? I can't pass the password to pg_dump utility (I was 
trying to pass it via tty also) when running system() from perl.





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

* Re: dumping a password-protected db from a perl script or a binary
  2002-11-04 13:32 dumping a password-protected db from a perl script or a binary dima <_pppp@mail.ru>
@ 2002-11-04 15:12 ` Artur Pietruk <arturp@plukwa.pdi.net>
  2002-11-04 15:18   ` Re: dumping a password-protected db from a perl script or dima <_pppp@mail.ru>
  2002-11-05 09:24   ` Re: dumping a password-protected db from a perl script or dima <_pppp@mail.ru>
  0 siblings, 2 replies; 4+ messages in thread

From: Artur Pietruk @ 2002-11-04 15:12 UTC (permalink / raw)
  To: dima <_pppp@mail.ru>; +Cc: pgsql-admin

On Mon, Nov 04, 2002 at 04:32:38PM +0300, dima wrote:
> How can i dump a password-protected database using perl (DBI or pg) or C 
> (using libpq)? I can't pass the password to pg_dump utility (I was 
> trying to pass it via tty also) when running system() from perl.

	Isn't example below something like what you are trying to do:

====8<====
#include <stdio.h>
#include <stdlib.h>

int main(void) {
        system("export PGDATABASE=\"test\"; export PGPASSWORD=\"test\"; export PGUSER=\"test\"; psql");

        exit(0);
}
====8<====

	? Here psql should connect to db 'test' as user 'test', password
'test'. Check if it works with pg_dump.

	I hope that helps! BTW - there are also other ways to do that...
Check docs of your pg version. $PGPASSWORD is deprecated.

	Best regards,
-- 
--- Artur Pietruk, arturp@plukwa.net



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

* Re: dumping a password-protected db from a perl script or
  2002-11-04 13:32 dumping a password-protected db from a perl script or a binary dima <_pppp@mail.ru>
  2002-11-04 15:12 ` Re: dumping a password-protected db from a perl script or a binary Artur Pietruk <arturp@plukwa.pdi.net>
@ 2002-11-04 15:18   ` dima <_pppp@mail.ru>
  1 sibling, 0 replies; 4+ messages in thread

From: dima @ 2002-11-04 15:18 UTC (permalink / raw)
  To: Artur Pietruk <arturp@plukwa.pdi.net>; +Cc: pgsql-admin

>>How can i dump a password-protected database using perl (DBI or pg) or C 
>>(using libpq)? I can't pass the password to pg_dump utility (I was 
>>trying to pass it via tty also) when running system() from perl.
> 
> 
> 	Isn't example below something like what you are trying to do:
> 
> ====8<====
> #include <stdio.h>
> #include <stdlib.h>
> 
> int main(void) {
>         system("export PGDATABASE=\"test\"; export PGPASSWORD=\"test\"; export PGUSER=\"test\"; psql");
> 
>         exit(0);
> }
> ====8<====
> 
> 	? Here psql should connect to db 'test' as user 'test', password
> 'test'. Check if it works with pg_dump.

This doesn't work on my 7.2.1 installation :/
I need to run pg_dump actually.





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

* Re: dumping a password-protected db from a perl script or
  2002-11-04 13:32 dumping a password-protected db from a perl script or a binary dima <_pppp@mail.ru>
  2002-11-04 15:12 ` Re: dumping a password-protected db from a perl script or a binary Artur Pietruk <arturp@plukwa.pdi.net>
@ 2002-11-05 09:24   ` dima <_pppp@mail.ru>
  1 sibling, 0 replies; 4+ messages in thread

From: dima @ 2002-11-05 09:24 UTC (permalink / raw)
  To: Artur Pietruk <arturp@plukwa.pdi.net>; +Cc: pgsql-admin

>>How can i dump a password-protected database using perl (DBI or pg) or C 
>>(using libpq)? I can't pass the password to pg_dump utility (I was 
>>trying to pass it via tty also) when running system() from perl.
> 
> 
> 	Isn't example below something like what you are trying to do:
> 
> ====8<====
> #include <stdio.h>
> #include <stdlib.h>
> 
> int main(void) {
>         system("export PGDATABASE=\"test\"; export PGPASSWORD=\"test\"; export PGUSER=\"test\"; psql");
> 
>         exit(0);
> }
> ====8<====
> 
> 	? Here psql should connect to db 'test' as user 'test', password
> 'test'. Check if it works with pg_dump.
> 
> 	I hope that helps! BTW - there are also other ways to do that...
> Check docs of your pg version. $PGPASSWORD is deprecated.

Thanks to Artur! I solved my problem another way using his hint.
I needed to make backups of a non-constant set of DBs as a cron job. I 
connected to the main DB the usual way & made "select datname from 
pg_database". Then I setup the environment correctly & forked a child 
(pg_dump) for every DB in the list i got.
It will be a pity if $PGPASSWORD would dissapear in the future releases 
of PostgreSQL since users wouldn't be able to automate some DB 
maintainance tasks. I enjoy MySQL allowing to provide password @ the 
prompt actually. Maybe this feature would be added to Postgres later.






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


end of thread, other threads:[~2002-11-05 09:24 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-04 13:32 dumping a password-protected db from a perl script or a binary dima <_pppp@mail.ru>
2002-11-04 15:12 ` Artur Pietruk <arturp@plukwa.pdi.net>
2002-11-04 15:18   ` Re: dumping a password-protected db from a perl script or dima <_pppp@mail.ru>
2002-11-05 09:24   ` Re: dumping a password-protected db from a perl script or dima <_pppp@mail.ru>

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