#!/bin/sh # This script does personal backups to a rsync backup server. You will end up # with a 7 day rotating incremental backup. The incrementals will go # into subdirectories named after the day of the week, and the current # full backup goes into a directory called "current" # # Original by tridge@linuxcare.com # rsync-over-ssh improvements, dmo@linuxcare.com USER=dmo HOME=/home/$USER HOST=talisker.i.linuxcare.ca # the name of the backup machine BSERVER=backup.i.linuxcare.ca # the location on the target machine where your stuff goes TARGET=/data/people/$USER/$HOST # directories on to backup BDIRS="/home/$USER /var/spool/mail /project" # excludes file - this contains a wildcard pattern per line of files to exclude EXCLUDES=$HOME/cron/excludes export RSYNC_RSH="/usr/bin/ssh -i $HOME/.ssh/backup_key_dsa" BACKUPDIR=`date +%A` OPTS="-v --force --ignore-errors --delete-excluded --exclude-from=$EXCLUDES --delete --backup --backup-dir=$TARGET/$BACKUPDIR -a" export PATH=$PATH:/bin:/usr/bin:/usr/local/bin # the following line clears the last weeks incremental directory echo "Purging last week's backup for $BACKUPDIR" [ -d $HOME/emptydir ] || mkdir $HOME/emptydir rsync --delete -a $HOME/emptydir/ $USER@$BSERVER:$TARGET/$BACKUPDIR/ rmdir $HOME/emptydir echo "Transferring today's backup" # now the actual transfer for dir in $BDIRS; do rsync $OPTS $dir $USER@$BSERVER:$TARGET/current done echo "Done."