Rsync: 1, Time Machine: 0

11 Nov, 2008

I recently bought a Mac Mini to serve various purposes about the house - not least of which, as a remote backup server for my MacBook Pro.

At which point I spent several evenings wrestling with Time Machine, with limited success. I moved my existing (500G, external) drive to the Mac Mini, shared it, and nominated it as my backup volume. But:

Eventually, I gave up, and went looking for alternatives. After flirting with rdiff-backup and rsnapshot, I eventually did a little research and rolled my own rsync backup script:

#! /bin/sh

set -e 

snapshot_host=theLoungeRoomMac.local
snapshot_dir=/Volumes/WD_500/Snapshots/woollyams
snapshot_user=root
ssh_user=$snapshot_user@$snapshot_host

ping -o $snapshot_host > /dev/null || {
  echo "WARNING: can't see $snapshot_host -- skipping backup"
  exit 1
}

ssh $ssh_user "test -d $snapshot_dir" || {
  echo "ERROR: can't see $ssh_user:$snapshot_dir" >&2
  exit 2
}
  
snapshot_id=`date +%Y%m%d%H%M`

/usr/bin/rsync --archive --verbose \
  --delete --delete-excluded \
  --numeric-ids --extended-attributes \
  --one-file-system \
  --partial \
  --link-dest ../current/ \
  --relative \
  --max-size=50M \
  --exclude ".git" \
  --exclude ".svn" \
  /private/etc /Users/mdub \
  $ssh_user:$snapshot_dir/in-progress/

ssh $ssh_user "cd $snapshot_dir; rm -fr $snapshot_id; mv in-progress $snapshot_id; rm -f current; ln -s $snapshot_id $snapshot_dir/current"

Advantages over Time Machine are:

Feedback