Interview Prep/Linux/Disk, Capacity & Backups

How does `rsync --link-dest` create space-efficient snapshots?

AdvancedProductionDisk, Capacity & Backups
Answer

Each run creates a new dated directory; unchanged files are hard-linked to the previous snapshot instead of copied, so every snapshot looks like a full backup but only changed files use space.

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

Deleting an old snapshot directory only frees files no other snapshot links to.

All Linux questions Roadmap: Linux

More on Disk, Capacity & Backups