Field Notes

Rolling snapshots with rsync and hard links

February 2, 2026

I wanted a dated copy of a directory every night, without every copy costing the full size of the directory. rsync can do this with hard links: files that did not change are not copied again, they are linked to the same data as in the previous snapshot.

The command

today=$(date +%F)
rsync -a --delete \
  --link-dest=/backups/latest \
  /srv/data/ /backups/$today/
ln -sfn /backups/$today /backups/latest

On the very first run /backups/latest does not exist yet, so rsync prints a warning and makes a full copy. From then on only changed files take up new space.

Things to know

Cleaning up

A simple retention rule is to delete snapshot directories older than a number of days with find, but never the one that latest points to.

← All notes