This is a cron job that will automatically backup the controller database, retain a fixed number of backups, and optionally sync using rclone.
This will only backup the database, please be sure to separately take a backup of the /etc/default/computestacks
file. This is only generated once during installation and will not change.
This script will install our two scripts, and rclone.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/ComputeStacks/controller-backups/main/install.sh)"
Before proceeding, decide which storage system you will use: https://rclone.org/overview/
Use rclone config
to setup and configure your storage system. Take note of the name you give your storage account.
Add the following to /etc/default/computestacks
, and make any necessary changes
LOCAL_BACKUPS_TO_KEEP=7
RCLONE_PROFILE= # This is the name you set when using `rclone config`.
RCLONE_REMOTE_PATH= # bucket name. May also include path in bucket, example: mybucket/somepath
Use crontab -e
# Run everyday at 03:30
30 3 * * * /usr/local/bin/controller-backup >> /var/log/rclone/controller-backup.log 2>&1
# Run every 12 hours
0 */12 * * * /usr/local/bin/controller-backup >> /var/log/rclone/controller-backup.log 2>&1