From: | ratlhead(at)ratlhead(dot)com (ratlhead) |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Shell Script help for backup |
Date: | 2002-07-20 09:25:48 |
Message-ID: | fd9c5ab3.0207200125.1c9b0575@posting.google.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hey all,
I'm thinkin' maybe I should post this in a shell scripting group but
thought someone here may be able to help me out...
I'm lookin' to run a shell script through the crontab on a nightly
basis for backup, and not keep more than a week of backups. In those
terms, I have a script working.
But I wanna take the script to another level. Basically, I want it to
email me if pg_dump fails, but I'm having a hard time doing so.
here's what I got
#!/bin/bash
DATE=`date +%Y-%m-%d`
PGUSER=<my username>
PGPASSWORD=<my password>
export PGUSER PGPASSWORD
pg_dump <dbname> | gzip > /folder/pg_backup.$DATE.gzip
if [ !$? ]
then
find /folder/pg_backup/* -mtime 8 -exec rm -f {} \;
echo "The PostGreSQL backup for today completed successfully" | mail
ratlhead(at)ratlhead(dot)com
else
echo "The PostGreSQL backup for today was unsuccessful" | mail
ratlhead(at)ratlhead(dot)com
fi
The problem is that is always gets detected as being successful, even
if I say, comment out the export line of my user/pass. Any
suggestions on how I can detect whether or not it worked?
Something else I'll be lookin' to do is FTP'ing the backup to another
server. If anyone has suggestions on where I can look for help on
that, it'd be great.
Thanks!
From | Date | Subject | |
---|---|---|---|
Next Message | Curt Sampson | 2002-07-20 09:30:42 | Re: Linux max on shared buffers? |
Previous Message | stefan | 2002-07-20 07:39:52 | Re: id and ID in CREATE TABLE |