One of the most standard ways to run tasks in the background on Linux machines is with cron jobs. They’re useful for scheduling tasks on the VPS and automating different maintenance-related jobs. “Cron” itself is a daemon (or program) that runs in the background. The schedule for the different jobs that are run is in a configuration file called “crontab.” I’ll be logged in as root.
Step 1 – Create file and paste backup script in it.
Step 2 – Make file executable.
Step 3 – Open file with the following commands:
Step 4 – Add backup script. For example I will show you how to backup your folder every day in different folders. If you want you can make backup on every hour in the same or in different folder. Add the following basic script. This script will create folder every day with the ‘date name’.
mkdir -p /home/backupcontentfolder/`date +%d-%m-%y-%H`/
rsync -raz /youfolder /home/backupcontentfolder/
Step 5 – Open crontab. If you open crontab with nano you will not have any problems but if you open crontab with vi or vim you should see sintaxis.
Step 6 – Make the following script executable every day or every hour or every two hours. I will show you the various options.
#Оnce at night
* 1 * * * /root/backup_script.sh
#0nce every two hours
* */2 * * * /root/backup_script.sh
#Once every five minutes every two hours
*/5 */1 * * * /root/backup_script.sh
#Once fifteen minutes past seven
5 7 * * * /root/backup_script.sh
9 Theme – How to add second hdd (additional hard drive) in Ubuntu 14.04 (Linux) Step-by-step