A Better & More Efficient Backup Solution

Most backups consist of just copying files to a different directory or even hard drive/tape drive.

A good backup solution is to use rsnapshot. Rsnapshot is a filesystem backup utility based on rsync. Using rsnapshot it is possible to take snapshots of your filesystems at different points in time. Using hard links, rsnapshot creates the illusion of multiple full backups, while only taking up the space of one full backup plus differences.

  • rsnapshot can backup local filesystems or use ssh for remote backups.
  • rsnapshot is written in Perl, and depends on rsync.

rsync works by synchronising files and directories from one location to another, while minimising data transfer using delta encoding. So if files do not change then they are not re-copied, this also minimises on bandwidth. It can also be set to make an exact copy of a directory – including file permissions, date and time, and symlinks.

Once installed, the main configuration file is rsnapshot.conf. The file contains settings for the directories to backup, where to store them and how often to run (called intervals).

Intervals

The interval specifies how often a backup should run (e.g daily) and also the number of copies to keep. For example the interval could be set as follows:

interval daily 7
interval weekly 4
interval monthly 3

The above settings will do a daily backup and keep 7 copies, a weekly backup and keep 4 copies, and a monthly backup and keep 3 copies. The monthly backup will not transfer any files over, it will simply take the oldest weekly backup and rename it. The weekly works the same – it will simply rename the oldest daily backup.

The directory structure will look like this :

daily.0 → Latest backup.
daily.1
.
.
daily.6
weekly.0
weekly.1
weekly.2
weekly.3
monthly.0
monthly.1
monthly.2 → Oldest backup.

How it runs (cron)

rsnapshot will be run via a cron job. The crontab entry will look similar to :

10 00 1 * * rsnapshot monthly
20 00 * * 0 rsnapshot weekly
30 00 * * * rsnapshot daily

The monthly backup will run at 00:10 on the 1st of the month.
The weekly backup will run at 00:20 on a sunday (day 0).
The daily backup will run everyday at 00:30.

Its important to run the monthly before the weekly, and weekly before the daily.

This backup solution will allow for keeping multiple copies, minimise disk space by using hardlinks and minimise bandwidth as only file changes will be copied. Restoring is also straightforward as the file can be found and simply copied into place.

rsnapshot – http://rsnapshot.org/

This entry was posted in Managed Hosting and tagged . Bookmark the permalink.

Comments are closed.