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.
More on Disk, Capacity & Backups
How do you lay out filesystems on a production server?IntermediateHow do you do capacity planning for disk?IntermediateWhat disk usage alert thresholds do you use?BeginnerA disk is 100% full in production. What do you do first?BeginnerHow do you clean up disk space safely on Docker hosts?IntermediateWhat is the 3-2-1 backup rule?Beginner