explain rsnapshot incremental rotation

Need help on rsnapshot. I am doing full backup every week with bash scripting which is costly for disk space. Now I am thinking to use rsnapshot and what I want to do with rsnapshot is do a weekly incremental backup and monthly full backup. So, this is how I configure the config file

retain gamma 4
retain delta 1

and schedule cronjob

00 00 * * * root rsnapshot gamma
00 00 1 * * root rsnapshot delta

I have a root folder for rsnapshot /root/rsnapshots/. Now with my understanding, For every weekly incremental backup, it will create hard links in these folders and new incremental backup will be on gamma.0

  • /root/rsnapshots/gamma.0
  • /root/rsnapshots/gamma.1
  • /root/rsnapshots/gamma.2
  • /root/rsnapshots/gamma.3

and every month does it copy all gamma.3 content to /root/rsnapshots/delta.0 or does it copy all gamma.0 content to /root/rsnapshots/delta.0?

Could anyone please explain to me here, how this rotation works? I am asking it because testing this kind of weekly and monthly rsnapshot is impossible for me with VM's.

Thank You


Where does the data go to

First you have to understand that only the gamma (lowest level) backups actually copy any data, all the others just rotate (aka rename) and delete the already existing snapshots (the gamma does this aswell). (see below)

Second is that a hard linked file is just a single regular file appering in multiple locations in the file system. It will only be deleted once all appearances are deleted (it might still be present on disk after that, you just can't find it).

So no, your setup doesn't copy all data every month. The delta backups are just as incremental as the gamma ones. Just since you have only one delta backup it itself won't be incremental above anything else.

What happens on every invocation

To understand what happens on each invocation of a backup-level, I highly recommend the man page, specifically the section about the retain parameter in the config. To give you a different explanation (I took me a while to grasp the manpage aswell):

Lowest level

Every time you (or cron) invoke snapshot gamma

  • the gamma.3 (the highest possible gamma backup) will be deleted if it exists. This causes any file revisions only present in that snapshot to be truly lost. All files that didn't change afterwards appear in gamma.2 (as a hard link) and thus will persist. All files that didn't change since delta.0 appear in delta.0.
  • all gamma.X folders will be moved to gamma.(X+1). This is a simple rename operation.
  • a new snapshot gamma.0 will be created incremental above gamma.1. Again all files that didn't change won't be copied but instead whatever is in gamma.1 will just appear in the gamma.0 folder aswell (as hard link).

Higher levels

Every time any higher level (in your case delta) is invoked the same happens for the respective level, except for the new snapshot part. Instead gamma.3 (the last possible snapshot of the next lower level) is moved (aka renamed) to delta.0 (the invoked level's .0). All the gamma backup still refer to the delta backup for old version.

Highest level

The only thing different here is that since there is no earlier snapshot, all file revisions that are outdated in delta.0 (the highest level in your case) and would be present in delta.1 will also be lost.

Another way to look at this would be: If you somehow could actually delete every file (not just it's apperance) inside delta.0 (the last backup) all backups of files that didn't changed since then are gone.

PS: It is recommended to start the backup jobs from highest to lowest level, as otherwise the gamma.2 folder will be rotated to gamma.3 and then immediately to delta.0 leaving you without a gamma.3. A small delay (10 mins) here is plenty, as only a few rename and delete operations are done by the higher levels. Also the gamma backups might take very long, as they copy data, causing the timing and order to get lost.