Feb 4, 2011

How to make backup's with rsnapshot

Rsnapshot is a very easy to use backup system for linux.
There just a view steps to make it working.

In this scenerio we have a fileserver called fileserver.mydomain and a USB backup drive mounted at /opt/backupdrive


Installation

On Ubuntu or Debian just type:
apt-get update && apt-get install rsnapshot -y


Configuration

There is a main config file located at /etc/rsnapshot.conf
You need to change some lines in this file:

Around line 27 you have to change the snapshot_root to /opt/backupdrive
Around line 102 you have to set some intervals:
#interval    hourly 24
interval    daily 7
interval    weekly 4
interval    monthly 12

You could activate hourly intervals but it costs to much resources for a fileserver to make a hourly backup.

Now you can setup the backup sources. Around line 203 you can enter some line like:
backup /home/    fileserver.mydomain/
backup /etc/    fileserver.mydomain/
backup /var/www/    fileserver.mydomain/
backup /opt/stuff/    fileserver.mydomain/

These lines describe what rsnapshot has to backup.
(Example: backup /home/ directory on fileserver)

Now rsnapshot is prepared to backup some files.


Usage

You surely want rsnapshot to backup in some intervals so you don't have to do that manuel.
This is done by cronjobs. Just open /etc/crontab with the editor of your choice and add:

0 18 * * 1 root rsnapshot daily
0 18 * * 2 root rsnapshot daily
0 18 * * 3 root rsnapshot daily
0 18 * * 4 root rsnapshot daily
0 18 * * 5 root rsnapshot daily
0 18 * * 6 root rsnapshot daily

0 20 * * 7 root rsnapshot weekly
0 22 1 * * root rsnapshot monthly


Restore

If you want to restore some data you just need to look at your backupdrive.
Look for example at /opt/backupdrive/daily.0/fileserver.mydomain/.
There your files.

No comments:

Post a Comment