pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: dima <_pppp@mail.ru>
To: Artur Pietruk <arturp@plukwa.pdi.net>
Cc: pgsql-admin@postgresql.org
Subject: Re: dumping a password-protected db from a perl script or
Date: Tue, 05 Nov 2002 12:24:34 +0300
Message-ID: <3DC78E52.9000706@mail.ru> (raw)
References: <3DC676F6.9060900@mail.ru>
	<20021104151205.GK3354@yoda.plukwa.net>

>>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.






view thread (4+ messages)

Message-ID: <3DC78E52.9000706@mail.ru>
Permalink:  ../3DC78E52.9000706@mail.ru/
Also on:    postgresql.org/message-id/3DC78E52.9000706@mail.ru

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: _pppp@mail.ru, arturp@plukwa.pdi.net
  Subject: Re: dumping a password-protected db from a perl script or
  In-Reply-To: <3DC78E52.9000706@mail.ru>
  References: <3DC676F6.9060900@mail.ru> <20021104151205.GK3354@yoda.plukwa.net> <3DC78E52.9000706@mail.ru>

* 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