This script enables a ‘Time Machine alike’ backup of folders on a computer to a remote server. The script keeps daily snapshots by saving the deltas compared to the previous backup. The rest of the info is symlinked so you don’t end up using 7 times the required amount of disk space on the server.
I’ve been using this script quite some time to backup my Linux desktop to an NSLU2. I found it back during the spring clean of my archives and save it here for future reference.
#!/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" # Credits: tridge@linuxcare.com # directory to backup BDIR_LIST="/home /usr/share/jalbum" # excludes file - this contains a wildcard pattern per line of files to exclude EXCLUDES=excludes # the name of the backup machine BSERVER=hydra # your password on the backup server export RSYNC_PASSWORD=<insert_password_here> ######################################################################## # --exclude-from=$EXCLUDES BACKUPDIR=`date +%A` OPTS="--force --ignore-errors --delete-excluded --delete --backup --backup-dir=$BACKUPDIR -a --exclude-from=$EXCLUDES" export PATH=$PATH:/bin:/usr/bin:/usr/local/bin # the following line clears the last weeks incremental directory [ -d $HOME/emptydir ] || mkdir $HOME/emptydir echo "Clearing last weeks incremental directory..." rsync -vv --delete -a $HOME/emptydir/ backup@$BSERVER::backup/$BACKUPDIR rmdir $HOME/emptydir # now the actual transfer echo "Starting actual backup..." for BDIR in $BDIR_LIST; do rsync -vv $OPTS $BDIR backup@$BSERVER::backup/current done echo "Backup completed!"