Backup with rsnapshot

Jack Wallen
May 19, 2010
Updated • Mar 29, 2018
Backup, Linux
|
21

If you are looking for a command line utility to handle all of your Linux backup needs, you really need look no further than this tool that bases itself off of the perennial backup favorite rsync. Rsnapshot takes the rsync utility and makes it more useful than it already was.

With rsnapshot you can retain multiple point in time backups and rotate them as well. But that is not all you can do with rsnapshot. In fact, this tool is so flexible it would seem the sky is the limit.

In this article I am going to show you how to install and use the rsnapshot backup utility so that you too can have consistent, reliable backups for your Linux system - server or desktop.

Installation

Before you install you will need to make sure you have (at minimum) both rsync and perl installed on your machine. There are a few ways you can install rsnapshot. You can install from source by downloading the latest .tar.gz file (from the rsnapshot download page) and do the following:

  1. Open up a terminal.
  2. Change to the directory the newly downloaded file his being held.
  3. Issue the command tar xvzf rsnapshot-XXX.tar.gz (Where XXX is the release number) to unpack the archive.
  4. Issue the command cd rsnapshot-XXX to change into the newly created directory.
  5. Issue the command ./configure.
  6. Issue the command make to build the software.
  7. Issue the command make install to install the software.

You could also download and install the pre-compiled binary (in .rpm, .deb, etc) form and install from that. Another way to install rsync is to the open up your Add Remove Software tool, search for rsync, and install from there.

No matter how you install you will wind up with an executable (rsnapshot) in /usr/bin/ and a configuration file (rsnapshot.conf) in /etc. You are ready to begin configuring your backup.

Configuration

All of the configuration for rsnapshot happens in the /etc/rsnapshot.conf file. Open that up with your favorite text editor (you will need root privileges to do so)  and get ready to get your hands  a little dirty.

Because everyone's set up is different, I am only going to point you to the sections of the configuration file you need to edit for your needs. The configuration file is very well laid out, so you shouldn't have any trouble with the configuration. But just in case...

The first section you will need to set up is the SNAPSHOT ROOT DIRECTORY section. This is where you define the location where your snapshots will be stored.

The next section (since we are installing this on Linux) is to uncomment out the cmd_cp directive under the EXTERNAL PROGRAM DEPENDENCIES section. Also, in this section, if you plan on using Secure Shell (ssh) for remote backups, you will need to uncomment the cmd_ssh line.

The next section is the BACKUP INTERVALS section. Here you have three (with an options fourth) options to set up:

  • hourly
  • daily
  • weekly

The default is set up nicely like this:

interval hourly 6
interval daily 7
interval weekly 4

This means you will have six hourly backups (every four hours), seven daily backups (once a day), and four weekly backups (once a week).

The final section you need to configure is the BACKUP POINTS / SCRIPTS section. Here you are going to define what is to be backed up. By default rsnapshot will back up /home, /etc, and /usr/local to the locally defined backup point. You will notice after this section is a very well laid out section of sample backups. Take a look at these closely as they will help you create various types of backups (including remote backups).

Final step - cron

The last thing you need to do (after you save your configuration file) is to set up cron to run the rsnapshot tool. You will want to set up the root users cron for this (so Ubuntu-based distributions will use the command  sudo crontab -e) so issue the command:

crontab -e

and add something like:
0 */4 * * * root /usr/bin/rsnapshot hourly
0 23 * * * root /usr/bin/rsnapshot daily
0 23 * * 6 root /usr/bin/rsnapshot weekly
The above will run rsnapshot hourly ever four hours, daily at 11pm, and weekly on saturday at 11pm.

That's it. You're backup is ready to go.

Final thoughts

Make sure you put some thought into your backup plan. After all, it will save you should a disaster strike. The rsnapshot tool is a very handy tool that can take the venerable rsync utility and make it far more useful.

Summary
Article Name
Backup with rsnapshot
Description
In this article I am going to show you how to install and use the rsnapshot backup utility so that you too can have consistent, reliable backups for your Linux system - server or desktop.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. prupert said on May 19, 2010 at 5:36 pm
    Reply

    rsback is another alternative, I use it every day, works really well:

    http://www.pollux.franken.de/en/backup/rsback/

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.