[KLUG Members] Postgresql + $HOME/.pgpass
Richard Zimmerman
ke4rit at knbpower.com
Tue Nov 1 13:24:31 EST 2005
Bruce Smith wrote:
>Switch to a valid user in root's crontab. This works for me:
>
> su -l postgres -c "/usr/bin/pg_dumpall > backups/dumpall 2> stderr" < /dev/null
>
> - BS
>
>
Sorry it took so long to reply to this... Finally got it to work with a
little tweaking... For Debian users, drop the -l from the example
above and it works fine. I ended up with the following:
Crontab:
# Postgresql
00 02 * * * su postgres -c "/etc/cron/postgresql" (Yes, I want the output)
/etc/cron/postgresql:
cmd> ls -al /etc/cron/postgresql
-rwxr-x--- 1 root postgres 295 Nov 1 13:09 /etc/cron/postgresql
*** and ***
cmd> cat /etc/cron/postgresql
#!/bin/sh
#
# Richard Zimmerman
# Created: October 7, 2005
# Updated: November 1, 2005
#
# Postgresql Server / Dump it / Vacuum it / HUP it
/usr/bin/pg_dumpall -vc > /work/postgres/postgresql.dump
vacuumdb amtpower
vacuumdb knbpower
vacuumdb laptrans
/etc/init.d/postgresql-7.4 restart
and finally:
cmd> ls -al /work/postgres/postgresql.dump
-rw-rw---- 1 ke4rit postgres 0 Nov 1 13:14 /work/postgres/postgresql.dump
FWIW....
Thanks for the help! I learned today... This is good!
Richard
--
Richard "Goose" Zimmerman
Safety Assistant / IT Guru
K&B Transport, Inc. - Elkhart, IN
(574) 389-1986 (574) 389-8527 Fax
(800) 548-2718 (574) 850-5764 Cell
More information about the Members
mailing list