Optional - Automating Backup Script with Cron


NOTE This is one method of automating the backups using the included backup script. 

Optional Automation of Backups with Cron and Expect

To automate the backups, perform the following:

  1. Edit the /etc/crontab file to schedule the tasks:
    # vim /etc/crontab
  2. Enter the schedule you would like to run.

    In this example, we have two entries. One to create the backup that will run at 1AM system time and another to delete more than 10 log files that runs at 2AM system time.

    #Run Backup
    * 1 * * * root /opt/PrimeKey/support/system_backup.sh -e supersecretpassword
    #Prune backups after 10 total
    * 2 * * * root /opt/PrimeKey/support/system_backup.sh --delete-files 10
  3. To output these entries to log files of their own for testing and validation, use the following entries:
    #Run Backup and log to file
    * 1 * * * root /opt/PrimeKey/support/system_backup.sh -e supersecretpassword >> /var/log/cron.log 2>&1 
    #Prune backups after 10 total and log to file
    * 2 * * * root /opt/PrimeKey/support/system_backup.sh --delete-files 10 >> /var/log/cron2.log 2>&1