Create an automatic backup using anacron
With cron, you schedule a job at a specific time and date. It assume that the machine is running continuously. But what if the machine is down? You have to wait until the next schedule and so on. This is where anacron can be useful. Using it you can schedule tasks on a daily, weekly or monthly basis. It is indeed an advanced cron.
Anacron can be used to execute commands periodically with a frequency specified in days. For each job, Anacron checks whether this job has been executed. If not, Anacron runs the job's shell command, after waiting for some minutes which is specified in the delay parameter. If there is no more job to be run anacron exits.
While cron can be specified to run at any intervals as small as a minute. Anacron on the other hand can be run in intervals of days.
This won't be a problem if you are taking backups.
We will setup an rsync backup for a system.
[chia$] su -c 'vim /etc/anacrontab'
Add the following line
1 10 backup rsync -auz -e "ssh -i /home/user/.ssh/rsync" /file username@ipaddress:~/backup
This means that the command will run every day(1st parameter) with a delay parameter of 10 minutes(2nd parameter) and identify the job in logs as 'backup' (3rd parameter)



























Post new comment