. .

Backup & Restore using rsnapshot

rsnapshot is a superior utility for remote and local backup. By using rsync and hard links, it could keep multiple full backup by storing only the difference which could preserve a lot of disk space. Moreover, windows machine could be backup by using SAMBA mount.

This post is base on Slackware 13.37.

Building and installation

> ./configure --prefix=/usr/local/rsnapshot
> make
> make install

Configuration

The above installation store the configuration file as /usr/local/rsnapshot/etc/rsnapshot.conf. You should modify the options in this file to suit your site.
Remeber, should be used as field separator and space is not correct, e.g.,

snapshot_root>TAB&lit;/mnt/backup/rsnapshot/ #corrent
snapshot_root /mnt/backup/rsnapshot/     #wrong

Suggested option

snapshot_root   /mnt/backup/rsnapshot/
no_create_root  1
retain        daily   7
retain        weekly  4
retain        monthly 3
logfile         /var/log/rsnapshot
rsync_short_args        -a
rsync_long_args --delete --numeric-ids --relative --delete-excluded --inplace
one_fs          1
link_dest       1
sync_first      1

Backup points

rsnapshot support a lot of backup point options, e.g., backup using ssh, rsync, LVM, or even backup the output of a script. You should refer to the man page for more information. But I would take the note about you could override the default options for each backup points at the third column, e.g.

backup  root@host.xyz.com:/home/xyz/program/ host.xyz.com/   +ssh_args='-p 7001',+rsync_long_args=--bwlimit=3500,+rsync_short_args=-z

The example indicate rsnaphot should backup the remote site thru ssh on port 7001 and there are some rsync options specific for the backup point.

Running the backup

You may specific some crontab entries to execute the backup. Or, you may create some shell script and placed them into /etc/cron.daily, /etc/cron.weekly & /etc/cron.monthly.
For example, the shell script in /etc/cron.daily

#!/bin/sh
/usr/local/rsnapshot/bin/rsnapshot sync
/usr/local/rsnapshot/bin/rsnapshot daily

The shell script in /etc/cron.weekly

#!/bin/sh
/usr/local/rsnapshot/bin/rsnapshot weekly

The shell script in /etc/cron.monthly

#!/bin/sh
/usr/local/rsnapshot/bin/rsnapshot monthly

Remmber enable the execute bit of the above script.

Post installation

Roate the rsnapshot log

In the /etc/logrotate,d directory create a file named ‘rsnapshot’, you may take the following as a sample:

/var/log/rsnapshot {
  compress
  rotate 10
}