Backups with rsnapshot

Even a rudimentary repository system is better than none. Learn how to create local and remote filesystem snapshots with rsnapshot.

The December 2004 “Tech Support” column, “Quick and Dirty Backups,” combined tar and rsync to make light work of backup regimens. The notion was that an easy to implement backup solution would encourage you to perform backups and archive more often. To this day, however, most home and small-business users still ignore backups- and do so at great risk.

Even a rudimentary repository system is better than none, so let’s look at another simple solution based on rsync. (A future “Tech Support” column will cover a more robust, scalable, and open source solution, such as Zmanda.)

rsnapshot is a Perl- based utility for saving snapshots of local and remote filesystems. It uses rsync and hard links to create multiple, full filesystem backups, yet only requires slightly more disk space than a single snapshot plus incremental archives. rsnapshot is licensed under the GNU Public License (GPL) and is hosted at http://www.rsnapshot.org/.

rsnapshot is simple to configure and can allow an end-user to restore his or her files without administrator intervention. Further, rsnapshot can keep an arbitrary number of hourly, daily, weekly, and monthly backups for any number of hosts. Pair rsnapshot with ssh to securely backup any remote machine in the same manner as a local machine would be backed up. You also can run scripts both before and after backup, which is handy for preparation, such as dumping a database to the filesystem for subsequent archival.

After you’ve download and unpacked the rsnapshot tarball, run the familiar ./configure command:

$ ./configure --sysconfdir=/etc

From there, simply run make install, short circuiting the normal make procedure, to install the resultant binary as /usr/local/bin/rsnapshot.

Next, create the configuration file. It’s easiest to copy the included rsnapshot.conf.default to /etc/rsnapshot.conf and use it as a foundation. (As backup needs vary greatly, configuration is beyond the scope of this article, but the configuration file provided as a sample is very well documented.) One facet you should give considerable thought to is backup intervals. This setting controls how often snapshots are taken and how long each is kept for archive.

Now decide what filesystems you want to snapshot. This is done using the parameter named backup. This parameter has two arguments: the directory or network path you’d like to backup, and the path, relative to snapshot_root, where the snapshot will be stored. For example, to backup the local /home directory, you might write:

backup	/home/		localhost/

Backing up remote systems is almost as easy as local ones:

backup	root@foo.com:/home/	foo.com/

Keep in mind that if you want this to work automatically, you must configure ssh key-based logins.

In addition to the backup parameter, you can use backup_script to run an arbitrary script as part of your backup regimen. This is extremely powerful, and can be used to dump remote databases, send notification messages, restart processes, or anything else you may need to do in your particular environment.

Once you’re done editing the configuration file, run rsnapshot configtest to ensure you don’t have any syntax errors. Next, run a test snapshot with rsnapshot –t interval, where interval is one of hourly, daily, weekly, or monthly and is configured lowest in your interval options (hourly by default). The -t option shows the work rsnapshot plans to perform, but doesn’t create any backups.

After you’ve verified all of your settings, add the appropriate settings to root’s crontab. For example, you might add…

0 */4 * * *       /usr/local/bin/rsnapshot hourly
30 23 * * * /usr/local/bin/rsnapshot daily

… to perform an hourly and daily backup, respectively, adhering to the rotation policy you’ve specified. You should now have rsnapshot configured to do automated multiple versioned backups. To restore, simply copy the files you need out of the appropriate snapshot directory.

rsnapshot has many advanced features, too. The manual walks you though secure NFS- mounted multiple user restores, filename filters, and removable media.

For many simple setups, rsnapshot is all you need to maintain a reliable backup solution. Keep in mind, though, that rsnapshot is a disk-based backup solution. While there are no tapes to change, it does have drawbacks, especially in some long-term archival situations.

Whatever route you choose, make sure you have some regular backup regimen in place. Also, don’t forget to test a restore before it’s critical to use it. A word to the wise: If you’re running a business, seriously evaluate your backup paradigm and ensure what you’re doing meets your actual needs.

Comments on "Backups with rsnapshot"


Thanks for the heads up on rsnapshot. I hadn’t encountered this backup system before.

I would also like to recommend BackupPC ( http://backuppc.sourceforge.net/ ). I’ve found it to be absolutely fantastic. It uses rsync also, but also works over ssh to backup remote machines. Furthermore, it pools all backed up files to eliminate duplicates (across all backups) and compresses them.

I currently use BackupPC at my workplace to backup a large number of remote machines. The total size of files backed up is almost 1 Terabyte, but due to pooling, duplicate removal, and compression the actual size of the backup pool is only 100GB.

It ‘just works’ and keeps on working. It is far and away the best backup system I’ve ever used.




The documentation does not say much about restoring from backups. What would be the best method? Just using rsync in reverse?


The thing I like about rsnapshot is it’s easy to restore: just copy files from your chosen snapshot with a conventional method and you’re good. It’s also very quick and painless to set up unlike some of the other backup systems I’ve tried.

One thing I do with the remote ssh logins is restrict the key rsnapshot uses to only the relevant rsync command since it usually runs unattended. This saved my bacon when I had a box get compromised last month since the key couldn’t be used for anything else. =)

Hello! I know this is somewhat off topic but I
was wondering if you knew where I could get a captcha plugin for my comment form?
I’m using the same blog platform as yours and I’m having difficulty finding
one? Thanks a lot!

Look at my webpage :: YouTube

Im thankful for the article post.Really looking forward to read more. Awesome.

Really enjoyed this blog. Much obliged.

I know this if off topic but I’m looking into starting my own weblog and was wondering what all is needed to get setup? I’m assuming having a blog like yours would cost a pretty penny? I’m not very internet smart so I’m not 100 certain. Any suggestions or advice would be greatly appreciated. Appreciate it

Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You obviously know what youre talking about, why throw away your intelligence on just posting videos to your site when you could be giving us something enlightening to read?

Leave a Reply