Automated backup

Started by Robert Fitzpatrickabout 23 years ago3 messagesgeneral
Jump to latest
#1Robert Fitzpatrick
robert@webtent.com

I have a script that tars up dirs for me each night and I've added a
pg_dumpall function to the script, but having problem with
authentication. I created a .pgpass file in the root user folder with
the appropriate permissions (600). However, even though the script is
owned by root, it does not run. I guess the .pgpass file is not loading
unless root actually logs in. Can anyone shed light on the best way to
get pg_dump to work unattended or point me in the right direction.

--
Robert

#2Ken Godee
ken@perfect-image.com
In reply to: Robert Fitzpatrick (#1)
Re: Automated backup

Not sure if I'm reading your email correctly,
but I use several bash scripts to import data daily.
Even thought the cron/scripts are owned and run by
root, root doesn't have permissions with postgres
so your script can use the "su -c" command as a user who
has permissions, ie.
su - user -c "pg_dumpall"
The "-c" switch will run just one command and return to
previous user.

Show quoted text

I have a script that tars up dirs for me each night and I've added a
pg_dumpall function to the script, but having problem with
authentication. I created a .pgpass file in the root user folder with
the appropriate permissions (600). However, even though the script is
owned by root, it does not run. I guess the .pgpass file is not loading
unless root actually logs in. Can anyone shed light on the best way to
get pg_dump to work unattended or point me in the right direction.

--
Robert

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Fitzpatrick (#1)
Re: Automated backup

"Robert Fitzpatrick" <robert@webtent.com> writes:

I have a script that tars up dirs for me each night and I've added a
pg_dumpall function to the script, but having problem with
authentication. I created a .pgpass file in the root user folder with
the appropriate permissions (600). However, even though the script is
owned by root, it does not run. I guess the .pgpass file is not loading
unless root actually logs in. Can anyone shed light on the best way to
get pg_dump to work unattended or point me in the right direction.

First thing I'd check is whether $HOME is set in the script's
environment. Failing that, it might be some other environment variable
that you're depending on. Scripts launched from cron usually get only
a very circumscribed set of environment variables passed to them.

regards, tom lane