#!/bin/sh
###########################################################################
# rbackup.sh
#
# script to rsync a set of backup directories from HD 1 to HD 2.
# Important: Add the directories you wish to backup to the SOURCEDIRS
# variable, space-delimited.
# Also, don't forget to cron this script!
#
# (loosely based on http://www.scrounge.org/linux/rsync.html)
# w 6/1/09 horto
###########################################################################
# paths and such
RSYNC=/ffp/bin/rsync
SOURCEDIRS="/mnt/HD_a2/ffp \
/mnt/HD_a2/media/mp3 \
/mnt/HD_a2/media/pictures \
"
DESTINATION=/mnt/HD_b2/backups/HD_a2
DATE=`date`
# logfile. keep an eye on the space of it over time.
LOG=/mnt/HD_a2/logs/rbackup.log
# excludes file - Contains wildcard patterns of files to exclude.
# i.e., *~, *.bak, etc. One "pattern" per line.
# You must create this file.
EXCLUDES=""
# rsync options, for testing
# -v Verbose -vv More verbose. -vvv Even more verbose.
# -a Archive. Mainly propogate file permissions, ownership, timestamp, etc.
# -n Don't do any copying, but display what rsync *would* copy. For testing.
# NOTE: never use -z option, don't want to compress locally
#OPTS="-van"
OPTS="-va"
if [ ! -d $DESTINATION ] || [ ! -w $DESTINATION ]; then
echo "[$DATE] ERROR: Destination $DESTINATION does not exist or is not writable." >> $LOG
fi
for SOURCE in $SOURCEDIRS; do
if [ ! -d $SOURCE ]; then
echo "[$DATE] ERROR: Directory $SOURCE does not exist" >> $LOG
else
echo "" >> $LOG
echo "[$DATE]" >> $LOG
echo "Starting rsync of source directory $SOURCE ..." >> $LOG
$RSYNC $OPTS $SOURCE $DESTINATION >> $LOG
fi
done