Simple and space efficient backups with rsnapshot

I have been using rsnapshot on my raspberry pi for some time as a backup solutiona and I have to admin it works really well.

Installation was very easy:

sudo apt-get install rsnapshot

Once installed I have created a config file:

cp /etc/rsnapshot.conf.default /etc/rsnapshot.conf

There are some important values that can be customized, like storage path, but I will focus on backup interavals as that might not be obvious on first use:

retain      hourly  6
retain      daily   7
retain      weekly  4
retain      monthly 3

rsnapshot is configured how many of each backups should be kept. Each time rsnapshot is run with the hourly command, it will rotate the hourly.X directories, and then "copy" the contents of the hourly.0 directory (using hard links) into hourly.1.

When rsnapshot daily is run, it will rotate all the daily.X directories, then copy the contents of hourly.6 into daily.0. So hourly.0 will always contain the most recent backup and daily.7 will contain backup from week ago...

And we can run the rsnapshot:

rsnapshot hourly


rsnapshot daily

Now we can automate this task via crontab:

0   */4 * * *  /usr/bin/rsnapshot hourly 
0   3   * * *  /usr/bin/rsnapshot daily
0   2   * * 1  /usr/bin/rsnapshot weekly
0   1   1 * *  /usr/bin/rsnapshot monthly

It is good idea to run the larger backup intervals before the lower ones as if hourly backup will run for 45 minutes, it gives use time to finish before just running the difference in daily backup. Othervise daily might not be run at all since once backup is running other wont start.

If you need to restore any of the backup directory, any user with read permission can simply copy the whole direcotry to desired location. To see how big are the directories with backups, we can simply generate reports, by running command:

rsnapshot du