Automatically purge rotated backup without breaking rsync

1

How do I make sure locally deleted files have been rotated before deleting them on the server, whithout breaking incremental rsyncing?

I usually rsync my files into /backup/active/ on my server, which should always contain the latest mirror, and should reflect what's on the client to 100%. This entire folder will be rotated nightly to /backup/cold/ using ddar and online using tarsnap. I want to make sure that every snapshot that is rotated contains only the files that were actually on the clients at the time. How can I make sure that files that are deleted on the client also gets deleted in the backup, without breaking rsync or accidentally deleting non-rotated files?

I don't want to use rsync --remove because that might remove files that haven't been rotated and backed up yet. Nor can I just shift the entire /backup/ folder a rotation, because I need to keep rsync's incremental functions.

Arkenklo

Posted 2014-01-13T12:02:19.637

Reputation: 311

Maybe you should consider using rsync linking capabilities (--link-dest) to maintain a hierarchy of backups. – Der Hochstapler – 2014-01-13T12:12:19.503

I want to keep things simple to avoid mistakes, and hard links are one of the things I'm not yet comfortable enough using that I want to risk my backups. – Arkenklo – 2014-01-13T12:24:44.797

Answers

1

So the objective is to secure the backups, right? I assume we don't care how it works as long as it gets the job done.

So, whilst Oliver gives the right hint --link-dest there is no reason to reinvent the wheel unless you want to learn and make your own experiences.

rsnapshot was invented for this purpose, has been used for several years now, and if you want the sourcecode, you may find it available on github.

For a quick story of other users experiences, try to read this blog: http://rayed.com/wordpress/?p=1379 as it gives a quick sense of "lessons learned".

root-11

Posted 2014-01-13T12:02:19.637

Reputation: 190