Shell Script help for backup

Поиск
Список
Период
Сортировка
От ratlhead@ratlhead.com (ratlhead)
Тема Shell Script help for backup
Дата
Msg-id fd9c5ab3.0207200125.1c9b0575@posting.google.com
обсуждение исходный текст
Ответы Re: Shell Script help for backup  (strange@nsk.yi.org)
Список 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@ratlhead.com
else
  echo "The PostGreSQL backup for today was unsuccessful" | mail
ratlhead@ratlhead.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!

В списке pgsql-general по дате отправления:

Предыдущее
От: jhood@hmcon.com (Jeffrey Hood)
Дата:
Сообщение: Re: Query Performance...
Следующее
От: "Pankaj Naug"
Дата:
Сообщение: ...