I have several DBs in single claster. When I make
pg_dumpall -U postgres >file
it asks me for password exact times the number DBs I have. Even to do that manualy, it sucks. But I want to go even farther: how I can automate the process to put into cron?
On Mon, 2007-11-05 at 20:14 +0700, Strong wrote:
I have several DBs in single claster. When I make
pg_dumpall -U postgres >file
it asks me for password exact times the number DBs I have. Even to do that manualy, it sucks. But I want to go even farther: how I can automate the process to put into cron?
---- man psql
When the defaults aren’t quite right, you can save yourself some typing by setting the environment variables PGDATABASE, PGHOST, PGPORT and/or PGUSER to appropriate values. (For additional environment variables, see the documentation.) It is also convenient to have a ~/.pgpass file to avoid regularly having to type in passwords. See the documentation for more information.
If you don't know how to create bash script files and add scripts to cron, download webmin as it can set this all up for you quite easily.
Craig
On Monday 05 November 2007 06:14:02 Strong wrote:
I have several DBs in single claster. When I make
pg_dumpall -U postgres >file
it asks me for password exact times the number DBs I have. Even to do that manualy, it sucks. But I want to go even farther: how I can automate the process to put into cron?
change your pg_hba.conf file and set postgres (or the user you're trying this as) to 'trust'
A more secure way is to setup a .pgpass file or use pg_service. See the online postgres docs for more on these
On Mon, Nov 05, 2007 at 20:14:02 +0700, Strong strong_yethumble@pochta.ru wrote:
I have several DBs in single claster. When I make
pg_dumpall -U postgres >file
it asks me for password exact times the number DBs I have. Even to do that manualy, it sucks. But I want to go even farther: how I can automate the process to put into cron?
You can authenticate based on the peers uid since you are running the command on the server. The files where you set this up are pg_hba.conf and pg_ident.conf in /var/lib/pgsql/data. You can also use a ~/.pgpass file, but using the uid base authentication is probably safer.
Once you do this you should be able to just put the dumpall command in cron. Though you might also want to do some sanity checking to make sure the dump succeeded (in case the disk filled up or something) and send a message if things look wrong.