If you de-dup things you're only syncing 5 directories: /root/, /boot/, /etc/, /usr/ and /home/joe/, the latter of which has an --exclude=/home/joe/.cache/ clause. So, while not being exactly what you're asking for, you could:
Code:
#!/bin/bash --
set -vx
grep -q -m1 "root-backup" /proc/mounts || exit 1
SRCS="/root/ /boot/ /etc/ /usr/ /home/joe/"
TRG="/media/root-backup/"
OPT="-nav --numeric-ids --delete --delete-excluded "
for SRC in $SRCS; do
case $SRC in
/home/joe/) EXCLUDES="--exclude=/home/joe/.cache/";;
*) unset EXCLUDES;;
esac
rsync $OPT $SRC $TRG $EXCLUDES
done
exit 0
*Note I added a "set -vx" line so you can see the script execute with all the vars filled in (comment that line out when done debugging) and the rsync "-n" switch (remove when you're satisfied --dry-run shows no problems).