Menu

Install and configure rsnapshot on RHEL/Centos 6/7

This tutorial will describe how to set up and use rsnapshot, a remote backup solution based on rsync. Rsnapshot leverages the power of rsync to create scheduled, incremental backups.

This procedure will demonstrate how to create local backups, as well as how to use another cloud server or your home computer as backup space. To complete the procedures in this tutorial, you will need to be logged in as root or preface all commands with "sudo".

To install rsnapshot through yum we need to install and enable third-party repository called EPEL.
RHEL/CentOS 7 64 Bit
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# rpm -ivh epel-release-7-5.noarch.rpm
RHEL/CentOS 6 32 bit
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
RHEL/CentOS 6 64-Bit
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
After installation EPEL Repository use the following yum command to install rsnapshot.
# yum install rsnapshot
Configuring Rsnapshot
Now open rsnapshot.conf file with vi or nano editor.
# vi /etc/rsnapshot.conf
Next create a backup directory, where you want to store backup of your important data. In my case I will create my backup directory called "/home/backup/". Search following line in /etc/rsnapshot.conf and add following parameter to set where you want to store all your important data as backup.
snapshot_root                           /home/backup/
Also uncomment the"cmd_ssh" line to allow to take remote backups over SSH.
cmd_ssh                                  /usr/bin/ssh
Next step is that, you need to decide how many old backups you would like to keep.This will take backup every six hours on a day but you can set your own schedule as per your requirements such as hourly, daily, weekly and monthly basis.
#           BACKUP INTERVALS            #

# Must be unique and in ascending order #

# i.e. hourly, daily, weekly, etc.      #

#########################################

 

interval        hourly  6

interval        daily   7

interval        weekly  4

interval        monthly 3
Backup Local Directories
If you want backup your directories locally to the same machine then follow the steps.  If you want take a backup from windows client then first you need to mount directory in Linux machine.
backup             /hackthesec/                    localhost/

backup             /etc/                           localhost/
Backup Remote Directories
If you want to backup up remote server directories then you need to follow the easy steps. I am taking a backup of my remote server "/home" directory under "/home/backup" directory on rsnapshot server.
backup        root@example.com:/home/             /home/backup/
Verify Rsnapshot Configuration
# rsnapshot configtest
# rsnapshot -t hourly
Automating the Process
Now i will show you how to schedule our backup process. In Linux we use cron jobs in order to schedule task. By default, rsnapshot comes with cron file under "/etc/cron.d/rsnapshot", if it’s doesn’t exists create one and add the following lines to it. If rules already exist then you need to remove the "#" from of the scheduling section to enable these values.
# This is a sample cron file for rsnapshot.
# The values used correspond to the examples in /etc/rsnapshot.conf.
# There you can also set the backup points and many other things.
#
# To activate this cron file you have to uncomment the lines below.
# Feel free to adapt it to your needs.
0 */4 * * * root /usr/bin/rsnapshot hourly
 
30 3 * * * root /usr/bin/rsnapshot daily
 
0 3 * * 1 root /usr/bin/rsnapshot weekly
 
30 2 1 * * root /usr/bin/rsnapshot monthly
www.hackthesec.co.in

About Author:


I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Next
Newer Post
Previous
Older Post

0 comments:

Post a comment

 
Top