Rsnapshot

Introduction
rsnapshot is a filesystem snapshot utility. It can take incremental snapshots of local and remote filesystems for any number of machines.

Local filesystem snapshots are handled with rsync(1). Secure remote connections are handled with rsync over ssh(1), while anonymous rsync connections simply use an rsync server. Both remote and local transfers depend on rsync.

rsnapshot saves much more disk space than you might imagine. The amount of space required is roughly the size of one full backup, plus a copy of each additional file that is changed. rsnapshot makes extensive use of hard links, so if the file doesn't change, the next snapshot is simply a hard link to the exact same file.

rsnapshot will typically be invoked as root by a cron job, or series of cron jobs. It is possible, however, to run as any arbitrary user with an alternate configuration file.

is the default configuration file.

Links

 * Rsnapshot
 * Manual
 * FAQ
 * How To

Syntax
rsnapshot [-vtxqVD] [-c cfgfile] [command] [args]

All important options are specified in a configuration file, which is located by default at . An alternate file can be specified on the command line. There are also additional options which can be passed on the command line.

The command line options are as follows:

-v verbose, show shell commands being executed

-t test, show shell commands that would be executed

-c path to alternate config file

-x one filesystem, don't cross partitions within each backup point

-q quiet, suppress non-fatal warnings

-V same as -v, but with more detail

-D a firehose of diagnostic information

Usage
rsnapshot can be used by any user, but for system-wide backups you will probably want to run it as root.

Since backups usually get neglected if human intervention is required, the preferred way is to run it from cron.

When you are first setting up your backups, you will probably also want to run it from the command line once or twice to get a feel for what it's doing.

Here is an example crontab entry, assuming that intervals hourly, daily, weekly and monthly have been defined in

0 */4 * * * /usr/local/bin/rsnapshot hourly 50 23 * * * /usr/local/bin/rsnapshot daily 40 23 1,8,15,22 * * /usr/local/bin/rsnapshot weekly 30 23 1 * * /usr/local/bin/rsnapshot monthly

This example will do the following:

6 hourly backups a day (once every 4 hours, at 0,4,8,12,16,20)

1 daily backup every day, at 11:50PM

4 weekly backups a month, at 11:40PM, on the 1st, 8th, 15th, and 22nd

1 monthly backup every month, at 11:30PM on the 1st day of the month

It is usually a good idea to schedule the larger intervals to run a bit before the lower ones. For example, in the crontab above, notice that daily runs 10 minutes before hourly. This helps prevent race conditions where the daily would try to run before the hourly job had finished. This is where the lockfile parameter really comes in handy.

Remember that these are just the times that the program runs. To set the number of backups stored, set the interval numbers in

To check the disk space used by rsnapshot, you can call it with the du argument.

For example:

$ rsnapshot du

This will show you exactly how much disk space is taken up in the snapshot root. This feature requires the UNIX du command to be installed on your system, for it to support the -csh command line arguments, and to be in your path. You can also override your path settings and the flags passed to du using the cmd_du and du_args parameters.

It is also possible to pass a relative file path as a second argument, to get a report on a particular file or subdirectory.

$ rsnapshot du localhost/home/

The GNU version of du is preferred. The BSD version works well also, but does not support the -h flag (use -k instead, to see the totals in kilobytes). Other versions of du, such as Solaris, may not work at all.

To check the differences between two directories, call rsnapshot with the diff argument, followed by two intervals or directory paths.

For example:

$ rsnapshot diff daily.0 daily.1 $ rsnapshot diff daily.0/localhost/etc daily.1/localhost/etc $ rsnapshot diff /.snapshots/daily.0 /.snapshots/daily.1

This will call the rsnapshot-diff program, which will scan both directories looking for differences (based on hard links).

$ rsnapshot sync

When sync_first is enabled, rsnapshot must first be called with the sync argument, followed by the other usual cron entries. The sync should happen as the lowest, most frequent interval, and right before. For example:

0 */4 * * * /usr/local/bin/rsnapshot sync && /usr/local/bin/rsnapshot hourly 50 23 * * * /usr/local/bin/rsnapshot daily 40 23 1,8,15,22 * * /usr/local/bin/rsnapshot weekly 30 23 1 * * /usr/local/bin/rsnapshot monthly

The sync operation simply runs rsync and all backup scripts. In this scenario, all interval calls simply rotate directories, even the lowest interval.

$ rsnapshot sync [dest]

When sync_first is enabled, all sync behaviour happens during an additional sync step (see above). When using the sync argument, it is also possible to specify a backup point destination as an optional parameter. If this is done, only backup points sharing that destination path will be synced.

For example, let's say that example.com is a destination path shared by one or more of your backup points.

rsnapshot sync example.com

This command will only sync the files that normally get backed up into example.com. It will NOT get any other backup points with slightly different values (like example.com/etc/, for example). In order to sync example.com/etc, you would need to run rsnapshot again, using example.com/etc as the optional parameter.