#!/bin/bash set -e R=~/tmp/bkd rm -rf $R mkdir -p $R # In my home directory, I keep a copy of the original rsync source code. mkdir -p $R/home/matt/rsync echo "rsync" >$R/home/matt/rsync/rsync.c # Soon I plan to make some changes to rsync, and I want $R/home/matt/rsync-test # to always contain my latest testing version. But for now, I'm just going to # make rsync-test a link to plain rsync. For some reason, I use an absolute # symlink. ln -s $R/home/matt/rsync $R/home/matt/rsync-test # The system is backed up. rsync -a --exclude="/backup*" $R/ $R/backup1/ # Now I'm ready to make my changes, so I replace the symlink with an actual # copy of the rsync source code. rm $R/home/matt/rsync-test rsync -a $R/home/matt/rsync/ $R/home/matt/rsync-test/ # The system is backed up again. The admin uses --link-dest to save space. rsync -a --exclude="/backup*" --link-dest="$R/backup1/" $R/ $R/backup2/ # Rsync incorrectly followed the symlink $R/backup1/home/matt/rsync-test # => $R/home/matt/rsync in the link-dest dir. As a result, # $R/backup2/home/matt/rsync-test/rsync.c is a hard link to $R/home/matt/rsync/rsync.c . # But for the moment, the backup is still OK. cat $R/backup2/home/matt/rsync-test/rsync.c # Now I start making my changes. echo "rsync with changes" >$R/home/matt/rsync/rsync.c # Uh-oh! Look what happened to the backup! cat $R/backup2/home/matt/rsync-test/rsync.c