Thread: pg_dump automatic

pg_dump automatic

From
"Enrico Comini"
Date:
Dear friends,
my problem is to make automatic dump of a database.
I have a .backup.sh file for dump containing:

#! bin/sh
pg_dump -U user database > dump.txt

I have a password on the database, so when the file is executed it prompt
for the password.
I try :
pg_dump < passfile -U user database > dump.txt
pg_dump -U user database < -passfile > dump.txt

but is the same.
How I have to do ? THANKS

Enrico



Re: pg_dump automatic

From
Andrew Sullivan
Date:
On Thu, Jan 23, 2003 at 11:41:05PM +0100, Enrico Comini wrote:
> I have a password on the database, so when the file is executed it prompt
> for the password.

You could try setting the PGPASSWORD environment variable in your
script.  I believe someone told me it was getting set to go away,
though, so it may not help.   If your OS supports it, ident over UNIX
domain sockets is more secure.

A

--
----
Andrew Sullivan                         204-4141 Yonge Street
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110


Re: pg_dump automatic

From
Tom Lane
Date:
Andrew Sullivan <andrew@libertyrms.info> writes:
> On Thu, Jan 23, 2003 at 11:41:05PM +0100, Enrico Comini wrote:
>> I have a password on the database, so when the file is executed it prompt
>> for the password.

> You could try setting the PGPASSWORD environment variable in your
> script.  I believe someone told me it was getting set to go away,
> though, so it may not help.   If your OS supports it, ident over UNIX
> domain sockets is more secure.

PGPASSWORD is insecure on platforms where others can see your
environment variables (which is quite a few Unixen, but not all).
I am not sure we will remove it, but as of 7.3 it's definitely
deprecated.  You can put passwords in ~/.pgpass instead.

ident for Unix sockets is a nice alternative if you can use it, too.

            regards, tom lane

Re: pg_dump automatic

From
Andrew Sullivan
Date:
On Fri, Jan 24, 2003 at 07:54:14PM -0500, Tom Lane wrote:
> deprecated.  You can put passwords in ~/.pgpass instead.

Right, I'd forgotten about .pgpass.  A better idea, to be sure.

A

--
----
Andrew Sullivan                         204-4141 Yonge Street
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110


Re: pg_dump automatic

From
Antti Haapala
Date:
> >> I have a password on the database, so when the file is executed it prompt
> >> for the password.
>
> > You could try setting the PGPASSWORD environment variable in your
> > script.  I believe someone told me it was getting set to go away,
> > though, so it may not help.   If your OS supports it, ident over UNIX
> > domain sockets is more secure.
>
> PGPASSWORD is insecure on platforms where others can see your
> environment variables (which is quite a few Unixen, but not all).
> I am not sure we will remove it, but as of 7.3 it's definitely
> deprecated.  You can put passwords in ~/.pgpass instead.

I think it could be a good idea to add an option which specifies which
file descriptor should be used for reading passwords?

Then shells could invoke programs like this:

   psql -U xyz template1 --password-fd=4 < my_data 4< /the/password/file/you/want/to/use

And there would be no need to use any files for Perl/C/etc.

--
Antti Haapala


Re: pg_dump automatic

From
Tom Lane
Date:
Antti Haapala <antti.haapala@iki.fi> writes:
> I think it could be a good idea to add an option which specifies which
> file descriptor should be used for reading passwords?

> Then shells could invoke programs like this:
>    psql -U xyz template1 --password-fd=4 < my_data 4< /the/password/file/you/want/to/use

Seems like a useless frammish ... what would you do with it that
wouldn't be better done with .pgpass?

            regards, tom lane

Re: pg_dump automatic

From
"codeWarrior"
Date:
Is your script running as postgres on your postgres data server ?

""Enrico Comini"" <algobit@algobit.com> wrote in message
news:PPEOLEBLEGFKDAOCDMLHEEOOHMAA.algobit@ALGOBIT.COM...
> Dear friends,
> my problem is to make automatic dump of a database.
> I have a .backup.sh file for dump containing:
>
> #! bin/sh
> pg_dump -U user database > dump.txt
>
> I have a password on the database, so when the file is executed it prompt
> for the password.
> I try :
> pg_dump < passfile -U user database > dump.txt
> pg_dump -U user database < -passfile > dump.txt
>
> but is the same.
> How I have to do ? THANKS
>
> Enrico
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org