Hi Greg,
On Thu, 19 Oct 2006, Greg Freemyer wrote:
I've looked at the examples at
address automated nightly scripts and error handling.
Are there some more complex examples available?
You need to implement locking yourself, in case a backup takes more than 24 hours. I use this:
LOCKFILE=/var/lock/backup-by-rsync.pid
if [ -r $LOCKFILE ]; then
OTHERPID=`cat $LOCKFILE`
if [ -n "$OTHERPID" -a -d "/proc/$OTHERPID" ]; then
echo "Another backup is already running:"
ps auxww | grep $OTHERPID | grep -v grep
exit 1
else
echo "Stale lockfile deleted: process $OTHERPID not running"
fi
fi
echo $$ > $LOCKFILE
rdiff-backup ...
rm $LOCKFILE
I'm backing up to a local directory on a dedicated backup disk so it is easy enough to add "rdiff-backup /src /backup" to my backup script.
But what about catching errors?
Seems like I should be sending output to a log file, grepping thru it and
e-mailing it to myself if anything goes wrong.
I used to let rdiff-backup write errors to the standard output, which means that they are included in cron's email. However, I get a load of errors of minor importance (UpdateError /some/file does not match source, socket path too long, etc.).
What I do now is write the output from rdiff-backup to a logfile, and check the return code ($?), and if it's greater than zero, I echo something which tells me which backup failed, and which logfile to check. This ignores the minor errors, but more major ones result in the appropriate warning.
Cheers, Chris.
--
_ ___ __ _
/ __/ / ,__(_)_ | Chris Wilson <0000 at qwirx.com> - Cambs UK |
/ (_/ ,\/ _/ /_ \ | Security/C/C++/Java/Perl/SQL/HTML Developer |
\ _/_/_/_//_/___/ | We are GNU-free your mind-and your software |
_______________________________________________