Re: Shell Script help for backup
От | ratlhead@ratlhead.com (ratlhead) |
---|---|
Тема | Re: Shell Script help for backup |
Дата | |
Msg-id | fd9c5ab3.0207221435.59e89f99@posting.google.com обсуждение исходный текст |
Ответ на | Re: Shell Script help for backup (david.morgan@s4c.co.uk) |
Ответы |
Re: Shell Script help for backup
|
Список | pgsql-general |
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
В списке pgsql-general по дате отправления: