rsync –link-dest for dated backups without dated disk usage

A dated directory per night is the easiest backup scheme to reason about and the fastest way to fill a disk: seven copies of a 40 GB document tree is 280 GB, and almost none of it changed between them. --link-dest points rsync at a reference directory and tells it to hard-link anything identical instead of transferring and storing it a second time.

TODAY=$(date +%F)
YESTERDAY=$(date -d yesterday +%F)

rsync -a --delete 
  --link-dest=/backup/shop/$YESTERDAY 
  -e ssh [email protected]:/var/www/shop/ /backup/shop/$TODAY/

Every snapshot is still a complete tree, so a restore is a plain cp out of whichever night you want, and deleting an old one only drops link counts rather than data a newer snapshot depends on. The cost moves from blocks to inodes, which matters on a tree of a million small files. A file rewritten in place breaks the link and is stored again in full — and so does a permission change, so a careless recursive chmod turns one incremental night into a full copy.