Which is best for backups rsync vs rdiff vs rsnapshot

rsnapshot uses rsync and cp -al to keep an historical archive with minimal extra storage. in short:

  • there's the 'last' copy, let's call it back-0
  • the previous copies are called back-1, back-2....

each copy 'seems' to be a full complete copy, but in fact any unchanged file is stored only once. it appears on several directories using hard links.

the process is simple, let's say there are currently 4 copies, back-0 through back-3. when rsnapshot is invoked, it:

  • deletes the oldest copy: back-3 (rm -r back-3)
  • renames back-2 to back-3 (mv back-2 back-3)
  • renames back-1 to back-2 (mv back-1 back-2)
  • makes a 'link mirror' from back-0 to back-1 (cp -al back-0 back-1) this creates the back-1 directory but insteado of copying each file from back-0 to back-1, it creates a hardlink; in effect, a second reference to the same file. this second name is just as valid as the first one, and the file's data won't be removed from the disk until both names are deleted.
  • performs an rsync from the original storage to back-0. since the previous backup was still on back-0, this rsync is very fast (even on remote links, since it transfers only changes). a file that was changed since the previous backup is replaced on back-0 but not on back-1, breaking the link between them, so now you keep both versions. an unchanged file stays shared between both directories and won't require extra storage to keep the previous copies consistent.

once you get familiar with the procedure, you'll find it very handy. it's not complex at all, sometimes i do it manually to keep sporadic 'previous versions' at interesting points of time (just before an important upgrade, just after installing and configuring a system, etc)


A late answer on this FAQ: rsync is a copy/sync tool, very efficient for distant backups. rsnapshot and rdiff do more than a single backup: they keep a history of the backup. AFAIK, rdiff does it by keeping diffs of the files between each backup (differential backup), so the archives are not accessible as-is. OTOH rsnapshot uses hardlinks for identical files full copies of every changed files, so the archives are plain directories that users/admins can search from. So there are cases where each performs best.