Linux Time Machine
Rsync incremental backups with hard links. Save time and space. And your data.
Macs have automatic incremental backups built in through Time Machine
Linux has rsync, bash and cron. Rsync can use hard links for unchanged files: only files changed since the previous backup are copied. This saves a lot of time and storage space.
A few entries from my personal backup. As you can see, each day gets its own directory. Inside is a complete backup with every file from my workstation. Still, each day takes very little extra space, since only modified files are copied. The rest are hard links. (Don't mind the modification times - they are set by rsync to the last modification time of / on my workstation):
- Backup to a filesystem which supports hard and soft links. No problem except for FAT or NTFS (Microsoft).
- Mount the backup filesystem locally (NFS, USB-cable etc). I use a QNAP NAS which is mounted to /mnt/backup over NFS
- Mount your backup target
- Set configuration in backup.conf
- Set exclude paths in backup_exclude.conf
- Test with some small directory and -v:
sudo do_incremental_rsync.sh -v /some/test-directory
- Do a full system backup:
sudo do_incremental_rsync.sh. If /home is on a separate partition:
sudo do_incremental_rsync.sh /home /. The first full backup will take a long time since all files must be copied.
- Finally, set up to run nightly, as root, through cron. I recommend doing a full run early morning or just after midnight, see Notes below.
Check hard links
To verify that hard linking actually works, use the
stat command on a file in the latest backup which you know has not been changed for some time.
stat shows a field
Links: # which tells how many hard links a file has. My /etc/fstab hasn't changed for a long time: