From: | strange(at)nsk(dot)yi(dot)org |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Shell Script help for backup |
Date: | 2002-07-22 14:09:23 |
Message-ID: | 20020722150922.A8795@nsk.yi.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, Jul 20, 2002 at 02:25:48AM -0700, ratlhead wrote:
>
> #!/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?
The script always detects a successful dump because the last command in
the pipe is gzip and it always succeeds.
You could change the [ !$? ] to something like:
[ "$( zcat /folder/pg_backup.$DATE.gzip | head -c1 | wc -c )" -eq 1 ]
> 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.
Use ncftpput or scp with no passphrase.
Regards,
Luciano Rocha
--
Consciousness: that annoying time between naps.
From | Date | Subject | |
---|---|---|---|
Next Message | Elielson Fontanezi | 2002-07-22 14:12:46 | RES: Shell Script help for backup |
Previous Message | Elielson Fontanezi | 2002-07-22 13:59:30 | pgsql editor |