x
Loading
 Loading
Featured Paper: Xen Virtualization with Novell SUSE Linux
Hello, Guest | Login | Register

Backups with rsnapshot

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

Community Tools
RSS
Recommend This [?]
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
Users That Liked This [?]
No one yet. Be the first.
Tags:
Tag This!
 3 Comments (view all)

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.

Jeremy Garcia is the founder and administrator of LinuxQuestions.org, a free, friendly, and active Linux community that filters its email with SpamAssassin. Please send questions and feedback to jeremy@linuxquestions.org.

Read More
  1. Network Block Devices: Using Hardware Over a Network
  2. The Importance of Command Line Literacy
  3. Easy Backups with AMANDA
  4. Wizard Boot Camp, Part 10: Utilities You Should Know
  5. What's GNU, Part Four: find

3 Comments on Backups with rsnapshot »

 avatar
johneeboy3 said: +0  Add karma Subtract karma

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.

Cheers

John

July 19th, 2007 1:53 PM (permalink)
 
 avatar
jgabler said: +0  Add karma Subtract karma

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

July 20th, 2007 2:13 PM (permalink)
 
 avatar
augthecaveman said: +0  Add karma Subtract karma

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. =)

July 21st, 2007 4:50 PM (permalink)
 
Please log in to post a comment.
Don't have an account? Register now for free access to all of LinuxMagazine.com
ActivSupport
Linux Magazine has chosen ActivSupport as IT consultants.
Sponsored Links