Backup with rsnapshot
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.
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:
- Open up a terminal.
- Change to the directory the newly downloaded file his being held.
- Issue the command tar xvzf rsnapshot-XXX.tar.gz (Where XXX is the release number) to unpack the archive.
- Issue the command cd rsnapshot-XXX to change into the newly created directory.
- Issue the command ./configure.
- Issue the command make to build the software.
- 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.
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:
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:
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.
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.Advertisement