
Rsnapshot is an open source backup utility based on rsync which we are going to discuss in today’s blog It is written in perl language. We will be looking at how we can install and Configure Rsnapshot utility. It can take incremental backups of local and remote filesystems for any number of machines. It leverages the power of rsync to create scheduled, incremental backups.
rsnapshot makes it easy to make periodic snapshots of local machines, and remote machines over ssh. The code makes extensive use of hard links whenever possible, to greatly reduce the disk space required.
Let’s get started with Installation of Rsnapshot
Installing Rsnapshot Backup in Linux
If you’re using Red Hat based distributions then you can install Rsnapshot with , First you have to install and enable third-party repository called EPEL. After Enabling and Installing that You can run this command:
yum install rsnapshot
If You are using debian based distributions then for installations , Run the Commands
sudo apt-get install rsnapshot
Now if we want to take backup of remote system then we have to configure passwordless login. So you can find any tutorial for configuring that. After Configuring next we have to Configure Rsnapshot.
Rsnapshot Configuration
The rsnapshot configuration resides in /etc/rsnapshot.conf
, As you can see in the Screenshot when we checked this file , we get many parameters
As you can see the root directory where all the snapshots are stored is :
snapshot_root /var/cache/rsnapshot/
Also we have to uncomment the “cmd_ssh” line in order to allow remote backups over SSH.
After this you have to specify , How many old backups we wish to keep, We set these up under the BACKUP LEVELS / INTERVALS
section. We tell rsnapshot to retain a specific number of backups of each kind of interval.
retain [name] [number]
“name” refers to the name of this backup level (e.g., alpha, beta, so also called the ‘interval’). “number”
is the number of snapshots for this type of interval that will be retained. The value of “name” will be the
command passed to rsnapshot to perform this type of backup.
[root@localhost]# rsnapshot alpha
For this example, every time this is run, the following will happen:
<snapshot_root>/alpha.5/ will be deleted, if it exists.
<snapshot_root>/alpha.{1,2,3,4} will all be rotated +1, if they exist.
<snapshot_root>/alpha.0/ will be copied to <snapshot_root>/alpha.1/ using hard links.
Each backup point (explained below) will then be rsynced to the corresponding directories in <snapshot_root>/alpha.0/
Note :
Backup levels must be specified in the config file in order, from most frequent to least frequent. The first
entry is the one which will be synced with the backup points. The subsequent backup levels (e.g., beta,
gamma, etc) simply rotate, with each higher backup level pulling from the one below it for its .0 directory.
Example:
retain alpha 6
retain beta 7
retain gamma 4
If you are accessing a remote machine over SSH and the port to bind is not the default (port 22
), you need to set the following variable with the port number:
ssh_args -p 22222
Now there are various other options such as specifying what you want to backup, Suppose you want to take backup locally on the same machine then this is as easy as specifying the directories that you want to save and following it with localhost/
which will be a sub-directory in the snapshot_root
that you set up earlier.
Backup Remote Directories
If you would like to backup up a remote server directories, then you need to tell the rsnapshot where the server is and which directories you want to backup.
Finally, you are almost finished with the initial configuration. Save the “/etc/rsnapshot.conf” configuration file.
Verify Rsnapshot Configuration
Once you’ve done with your all configuration, its time to verify that everything works as expected. Run the following command to verify that your configuration has the correct syntax.
rsnapshot configtest
If everything configured correctly, you will receive a “Syntax OK” message. If you get any error messages, that means you need to correct those errors before running rsnapshot.
Running Rsnapshot Manually
The final step to test your configuration is to run rsnapshot in test mode. This will print out a verbose list of the things it will do, without actually doing them. To do a test run, run this command:
rsnapshot -t hourly
This tells rsnapshot to simulate an “hourly” backup. It should print out the commands it will perform when it runs for real
Conclusion
In this Blog we had a basic idea about installing and Configuring Rsnapshot Conf. file and We also learnt about How can manually test the Conf. File. If you want to learn more about Rsnapshot then you can visit Man page of this utility.
References :
The References for writing this blog were taken from : Link1 Link2