Optional - Automating Backup Script with Cron
NOTE This is one method of automating the backups using the included backup script.
The following covers optional automation of backups with Cron.
In this example, the flag -e is used with the backup script and the example password of "supersecretpassword" is used to encrypt the backups. Additionally, the -d flag is used to delete any quantity of backup files over 30 giving 30 days of files. It is recommended to mount a file system path to an S3 bucket and have the backups generated automatically to an S3 bucket.
As of EJBCA Cloud version 3.4.0, the -s and --use-openssl options must be used in combination with the -e flag to suppress prompts and force openssl encryption. Passwords should be wrapped in single quotes ('').
To automate the backups, do the following:
Edit the
/etc/crontabfile to schedule the tasks:CODE# vim /etc/crontabEnter the selected run schedule.
In this example, there are 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.CODE#Run Backup * 1 * * * root /opt/PrimeKey/support/system_backup.sh --use-openssl -s -e 'password123' #Prune backups after 10 total * 2 * * * root /opt/PrimeKey/support/system_backup.sh -d 30To output these entries to log files of their own for testing and validation, use the following entries:
CODE#Run Backup and log to file * 1 * * * root /opt/PrimeKey/support/system_backup.sh --use-openssl -s -e 'password123' >> /var/log/cron.log 2>&1 #Prune backups after 10 total and log to file * 2 * * * root /opt/PrimeKey/support/system_backup.sh -d 30 >> /var/log/cron2.log 2>&1