I use rsync
to back up large hard drives on a remote machine. By default, rsync
does not delete files on the remote machine when they no longer exist on the local machine. This is useful, because it makes it possible to recover, e.g., if I want to restore a file which was deleted by mistake, and it also means that I don't need to worry about rsync'ing an empty directory (if the hard drive dies or is not mounted). The problem is that it takes lots of disk space on the remote host, and also that if I need to restore a backup it will be polluted with these deleted files.
The alternative is rsync --delete
, but then it means that files that have been deleted will also get deleted the first time I run the backup, and if the mountpoint ever becomes empty then I risk deleting the backup as well.
Ideally I would like to have a way to tell rsync
to do like --delete
, but instead of deleting files, it could move them to a different backup hierarchy. That way, I could still restore these files if I wanted, and I could clean up the larger files in that second hierarchy to save space, while the main backup hierarchy would be a clean back-up of my drive.
Is there a way to emulate this behavior? (or some similar behavior)
(I don't have enough disk space to maintain two complete backups on the remote host. Also, I know about the existence of incremental backup tools like Borg Backup, but I'd like a solution that doesn't rely on heavy tools with a custom storage format. I'm also a bit wary of solutions using hard links but I'm OK with them if it's the best option.)
rsnapshot
?rsnapshot
. I'm using the answer below but was hoping for something more "snapshot" like. But thanks!