Hi all,
This is how I ended up solving my problem. Not sure if any of this
will help you, but here's the scripts I use. This is what it does...
-Uses PG environmental variables to connect to the PG server
-Dumps the specified database
-Checks the backup folder for any backups older than a week and
deletes those
-Checks to be sure the backup was successful by checking for a 0k file
for that day
-Sends email saying if backup was successful or failed
-If successful, checks the day and if it's Saturday, uploads most
current backup to specified ftp site
-.netrc file required for FTP connection
##### pg_backup.sh #####
#!/bin/bash
DATE=`date +%Y-%m-%d`
PGUSER=<my user>
PGPASSWORD=<my pass>
export PGUSER PGPASSWORD
/path/pg_dump <db name> | gzip > /path/pg_backup.$DATE.gzip
find /path/pg_backup/* -mtime 7 -exec rm -f {} \;
if test -s /path/pg_backup/pg_backup.$DATE.gzip
then
echo "The PostGreSQL backup for today was successful!" | mailx -s
"PostGreSQ
L backup successful" <email address>
/path/day_pg.sh
else
echo "The PostGreSQL backup for today failed!" | mail -s
"PostGreSQL backup
failed" <email address>
fi
##### day_pg.sh #####
DAY=`date +%a`
if [ $DAY = "Sat" ]
then
/path/upload_pg.sh
fi
##### upload_pg #####
DATE=`date +%Y-%m-%d`
ftp <host> << EOF
cd path
put /path/pg_backup.$DATE.gzip pg_backup.$DATE.gzip
quit
EOF
##### .netrc #####
machine <host> login <username> password <password>
-Mike Graben
ratlhead@ratlhead.com