↑ ↓ select, Enter open, Esc close

Incremental backup with hard links using rsync --link-dest

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
root@server
rsync -a --link-dest=/backup/example.com/aktuell /var/www/vhosts/example.com/httpdocs/ /backup/example.com/$(date +%F)/ && ln -sfn /backup/example.com/$(date +%F) /backup/example.com/aktuell

Creates a folder named after today’s date under the backup path. Files that have not changed since the last backup are created as hard links to the previous version via --link-dest and use no additional space. Afterwards, the aktuell symlink points to the new backup, which serves as the comparison base for the next run.

Note: Backup and previous version must be on the same filesystem. Old date folders can be deleted individually without damaging other snapshots.

Open question before approval: Prüfen, dass rsync beim allerersten Lauf ohne vorhandenes aktuell nur warnt, eine Vollkopie anlegt und mit Exitcode 0 endet, damit der Symlink gesetzt wird.

Also searched as

  • rsync snapshot backups
  • daily backups without using much space
  • time machine style backup linux
  • rsync incremental backup

Related one-liners

All in rsync and backup

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.