pg_dump automatic

Started by Enrico Cominiabout 23 years ago7 messagesgeneral
Jump to latest
#1Enrico Comini
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

#2codeWarrior
GPatnude@adelphia.net
In reply to: Enrico Comini (#1)
Re: pg_dump automatic

Is your script running as postgres on your postgres data server ?

""Enrico Comini"" <algobit@algobit.com> wrote in message
news:PPEOLEBLEGFKDAOCDMLHEEOOHMAA.algobit@ALGOBIT.COM...

Show quoted text

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

#3Andrew Sullivan
andrew@libertyrms.info
In reply to: Enrico Comini (#1)
Re: pg_dump automatic

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
#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Sullivan (#3)
Re: pg_dump automatic

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

#5Andrew Sullivan
andrew@libertyrms.info
In reply to: Tom Lane (#4)
Re: pg_dump automatic

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
#6Antti Haapala
antti.haapala@iki.fi
In reply to: Tom Lane (#4)
Re: pg_dump automatic

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

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Antti Haapala (#6)
Re: pg_dump automatic

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