Differential backups with rsync
I already knew how to backup a directory with rsync:
$ rsync -Pav --delete /path/to/dir1/ /path/to/dir2/
This is nice and good, but what if a file in dir1 becomes corrupted? Its corruption will be copied verbatim to dir2 and the backup will be of no use. Fortunately, there is a way to do differential backups with rsync:
$ rsync -Pav --delete --backup \
--backup-dir=/path/to/versions_dir \
--suffix='_$(date +"%Y%m%d%H%M%S")' \
/path/to/dir1/ /path/to/dir2/