In this recipe, we will show you how to do data backups, on a regular basis, that will take snapshots of some of your system's directory using the crond
daemon. This will run the rsync
program at regular intervals to implement a fully automated backup solution.
To complete this recipe, you will require a working installation of the CentOS 7 operating system with root privileges and a console-based text editor of your choice. It is also advantageous if you have read the Synchronizing files and doing more with rsync and Scheduling tasks with cron recipes in this chapter to get a deeper understanding of used commands.
It's important to install the rsync
program on your server before proceeding with this recipe.
First, log in as root and create a directory where our backups will land:
mkdir /backups
Now, we will create the following shell script file and open it for editing:
mkdir ~/bin;vi ~/bin/mybackup.sh
Put in the following...