If you are working as a system administrator, then it is your responsibility to protect organizations important data using proper way. it does not matter your organization is small or large, data is always important for any enterprise.
In computing term backup means, to save your critical data on remote location safely. Personally I recommend you to make multiple copies of backup of your backup. Having multiple copies of your data backup you can restore it easily if you are victim of these conditions:
database corruption, hardware failures, Physical computer damage, Virus Infection, and natural disasters.
In this tutorial we will use rsnapshot, which is powerful tool based on file system snapshot terminology written in Perl language.
rsnapshot is capable to schedule our backup jobs hourly, daily, weekly and monthly bases. It is a simple automated backup solution which is based on rsync.
To install rsnapshot through yum we need to install and enable third-party repository called EPEL.
RHEL/CentOS 7 64 Bit
RHEL/CentOS 6 32 bit
RHEL/CentOS 6 64-Bit
After installation EPELÂ Repository use the following yum command to install rsnapshot.
Â How to configure SSH Password-less Login coming soon!
Now open rsnapshot.conf file with vi or nano editor.
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 â€œ/data/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.
Also uncomment the â€œcmd_sshâ€ line to allow to take remote backups over SSH. To uncomment the line remove the â€œ#â€ in-front of the following line so that rsnapshot can securely transfer your data to a backup server.
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. We have already written a tutorial how to mount window based share folder in Linux.
backupÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /broexperts/Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 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 â€œ/data/backupâ€ directory on rsnapshot server.
Verify Rsnapshot Configuration
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.
# 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