Name Last modified Size Description
Parent Directory - .bzr/ 07-Feb-2008 14:43 - README.html 14-Mar-2008 15:17 15K rsnap-0.5.tar.gz 14-Mar-2008 15:21 6.1K rsnap-0.6.tar.gz 13-Nov-2008 01:39 7.8K
rsnap is a backup and snapshot utility based on rsync.
rsnap is available from as a Bazaar branch from http://web.chad.org/projects/rsnap/
To check out the most recent release, $ bzr branch http://web.chad.org/projects/rsnap/
rsnap N source[s] dest [-- rsync_options]
Where N are the number of snapshots you want to keep, source the source directories (local or remote) and dest the destination directory.
rsnap 7 email@example.com:/home/user/ ./backup/
If you have more than one source, then you probably shouldn't have slashes on the end of any.
Run this command every day and you will have backups going back a week. The backup directory will look like this:
Note that the oldest directory is 0006 and not 0007, because we started counting at 0.
If you need to pass parameters to rsync, just append them after a single "--".
rsnap 7 firstname.lastname@example.org:/home/user/ ./backup/ -- --exclude \*.o --bwlimit=8
Consider the following situation: You have set up a cronjob with rsync to create a backup of your website to your local computer. You run this cronjob every day to make sure you're not missing anything when you modify the website on the remote server. But what happens if someone breaks into your site, modifies it and you only notice that days, maybe weeks later? Or you rewrote big chunks of your website and feel this was a mistake but you can't go back because your backup already synchronized your changes and overwrote the old version?
Thats where snapshots are useful (snapshots are sometimes also referred to as "checkpoints"). rsnap will not only save the state of your files of the last backup, but it will also retain previous states - as many as you like. This is done in an efficient way, so that only files that have changed will occupy additional space. Even better, as rsnap is a thin wrapper around rsync which adds snapshot rotating and creation, the changes you need to make to your existing backup script are minimal.
If you are a developer, you might think of tools like CVS to be the answer to the problem mentioned above. Now while these tools are more powerful, they require you to learn a special syntax and they are generally more difficult to use. rsnap provides an ad-hoc, general-purpose, zero-headache backup and snapshotting tool which is extremely easy to use. Want to restore a backup from two days ago? Just copy it from the subfolder to your current folder using "cp". Want to see the differences between to snapshots? Just run a "diff" over these directories.
rsnap is useful if you have lots of small files which change infrequently, like a website or maybe even source code. It is useful for Maildirs too, but rsnap won't recognize, if a file has moved from new/ to cur/, so sometimes you will be wasting space (ideas on how to optimize this behaviour are welcome).
If you have lots of big files that all change frequently, don't use rsnap. For example you have lots of images or word files you are editing. Or you are using mbox files. Every time the file changes (or even if only the file's permissions change (this information is stored in the inode)), rsnap will create a new copy of it. In such cases, you might consider using rdiff-backup, which creates efficient binary deltas.
Do not use rsnap to create backups of your MySQL data directory. MySQL data files tend to change frequently which leaves you with inconsistent (=unusable) files. This is a limitation of rsync itself, not rsnap. Use mysqldump instead.
The idea behind rsnap came from an article by Mike Rubel, which can be found at:
The result of this article were probably thousands of tools, including this one, which none of them I liked (see section "Similar tools").
The basic idea of creating snapshots using rsync is to use hardlinks. rsync can do this automatically with the --link-dest option. For more details, read the article :)
$ ./setup.py install --prefix=/usr/local
Tools that provide snapshots, but are not related to rsync:
LVM allows to create consistent backups on block-level. All the changes you are making to the "current" Logical Volume propagate down to all snapshots you have created for it. So if you have created two snap- shots, you are using 3 times the space (one for the active, two for the snapshots) and evidentially you have 3 times as much writes on your disk.
Snapshots could be used in conjunction with rsnap, though, to create a consistent view from your drive.
rdiff-backup uses rdiff to create efficient binary deltas. Restoring the last backup is easy, as you can just copy the files out of the backup directory. Restoring previous backups requires to use rdiff-backup, which reconstructs the previous state using the deltas it created (and which were stored in a subdirectory called rdiff-backup-data). Actually a very nice tool, it just didn't handle errors gracefully and I ended up having to manually intervene very often. Also restoring files is not as intui- tive as it could be.
CVS / SVN / any other Source Control Management tool
Very powerful and recommended if you are managing source code. Not neces- sarily useful for everyday-use though (IMO).
Tools based around the documentation of Mike Rubel, using all rsync:
Of all the tools I tried, this is the one i liked most. It created sub- directories in a fashion I didn't like, though.
rsnapshot requires to write a configuration file which contains all the targed hosts.
suffers from same problem than rsnapshot, tries to be all-in-one-solution.