Fork me on GitHub

Anacron

Anacron is a utility which allows you to schedule commands. The functionality of anacron is the ability to run missed commands. Anacron is a good utility to schedule daily backups at night, because even if the machine is asleep or powered off at the scheduled time, when the machine is powered up or woken it will detect that a scheduled event was missed and will essentially begin the backup.

Anacron jobs are typically configured within the file : /etc/anacron.conf

For details regarding the anacron configuration file syntax please consult the anacron manual or webpage.



Anacron runs jobs as root. As such, if you wish to run a scheduled backup as user other than root then you will want to add something like below as the command section of the anacron configuration file :

Mac OS X Example

  Syntax  : /usr/bin/sudo -H -u <backup user name> "<backup command>"
  Example : /usr/bin/sudo -H -u bob "/usr/local/sbin/lbackup /etc/lbackup/bobsbackup.conf"



Other Approaches

Another approach is to use the example pre-action script which will prevent backups from taking place at intervals which are closer together than you would like to schedule. Essentially, the example script is able to detect the last time a backup was made and then abort the backup if not enough time has elapsed.



Helpful Links