Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
share|improve this question
    
Related: If your system is not on power 24/7, you probably want to use anacron, not cron. For more info, e.g. see: thegeekstuff.com/2011/05/anacron-examples –  Alex Jan 19 at 14:47

4 Answers 4

up vote 9 down vote accepted

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

share|improve this answer
    
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 ? –  Patrick Jan 8 '11 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 '11 at 16:52

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.

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.