11

A simple question about rsnapshot.

In order to perform daily backups I'm going to add lines to cron in my Ubuntu.

Then, why do I have also these lines in the rsnapshot.conf ?

#########################################
#           BACKUP INTERVALS            #
# Must be unique and in ascending order #
# i.e. hourly, daily, weekly, etc.      #
#########################################

interval        hourly  6
interval        daily   7
interval        weekly  4
#interval       monthly 3

If I use cron, should I disable them ? thanks

ps. I've just realized that in the crontab I still have "hourly" and "daily". Should I then uncomment only the one I use in the crontab ? And what's the point to specify hourly if it is already specified in cron ? I'm a bit confused.

# crontab -e
0 */4 * * * /usr/local/bin/rsnapshot hourly
30 23 * * * /usr/local/bin/rsnapshot daily
1

4 Answers 4

11

Your crontab job will call the relevant type of rsnapshot job to run. If you run rsnapshot hourly you will create a directory in your output directory called "hourly.0". Run it again, it will create "hourly.1".

So for every item you enable in your crontab, there should be a corresponding interval line in your /etc/rsnapshot file. If you decide not to use the hourly interval for example, then just leave the interval line in your configuration, but don't run an cron job that specifies "hourly".

The confusion only arises because the default names are "hourly" "daily" and so on. These are simply labels that can be changed to suit your needs.

For my rsnapshot, I use "daysago", "weeksago" and "monthsago" :

alt text

2
  • ok thanks, one last question. Let's say I have interval hourly 2 and 0 */5 * * * /usr/local/bin/rsnapshot hourly in crontab. In this case I perform the hourly backup every 5 hours and only 2 copies are kept on the backup server. Is this correct ?
    – aneuryzm
    Jan 8, 2011 at 14:03
  • That's right. You'll generate an hourly.0 and an hourly.1, every 5 hours. On the third iteration, hourly.1 is deleted, hourly.0 is renamed to hourly.1 and a new hourly.0 is created. And so on, constantly overwriting the oldest.
    – Scaine
    Jan 8, 2011 at 16:52
2

No, you shouldn't disable them.

The interval config tells rsnapshot

  • how many snapshots of each level to keep. In your example, after 6 "hourly" snapshots the oldest "hourly" is deleted.
  • where to get the contents of the current snapshot. The top entry (in your case "hourly") is copied from the source, while the remaining entries simply link to the latest snapshot from one level above.

The interval labels like "daily" and "weekly" don't mean anything (you could call them "x" and "y" if you wanted), but they must match the argument you pass in to rsnapshot when you call it.

In short, you need both - the interval config to tell rsnapshot how the different intervals relate, and the cron to execute it.

2

If you decide not to use the hourly interval for example, then just leave the interval >line in your configuration, but don't run an cron job that specifies "hourly".

This isn't quite right, at least not with the current version of rsnapshot.

The first "retain" line in rsnapshot.conf (e.g. 'hourly') tells which name to copy the current backup to. The rest rotate. From the man page:

Backup levels must be specified in the config file in order, from most frequent to least frequent. The first entry is the one which will be synced with the backup points. The subsequent backup levels (e.g., daily, weekly, etc) simply rotate, with each higher backup level pulling from the one below it for its .0 directory.

So, if you're not going to ever call rsnapshot hourly, your rsnapshot.conf shouldn't have a retain hourly line.

1

The "interval" directive actually replaces the "retain" in the previous versions. Yes, confusing, I know, but j-g-faustus explains it very clearly.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .