Backups¶
Accounting¶
Prerequisites¶
- Make sure the
ocicli tool is installed and properly configured. The backup and restore scripts rely on theocicli tool. - Make sure that a bucket named 'backups' exists in OCI.
Backing up Accounting¶
The following script dumps the accounting database to a file, compresses it, and uploads it to the 'backups' Object Storage bucket.
Automatic Accounting Backups¶
To set up a daily backup at midnight, add the following entry to the crontab:
/opt/oci-hpc/logs/backups/.
Clearing Accounting Data¶
Note: Before restoring Accounting data, you will need to drop the existing database.
mysql --defaults-extra-file=/home/ubuntu/.billing.cnf -e "DROP DATABASE billing;"
mysql --defaults-extra-file=/home/ubuntu/.billing.cnf -e "CREATE DATABASE billing;"
Restoring Accounting From a Backup¶
Note: Ensure Accounting database has been cleared (see Clearing Accounting Data section)
# 1. Located the desired backups in the backups bucket in OCI. Look for a file in the format
/accounting/accounting_backup_{year}_{month}_{day}.sql.gz
# 2. Download the backup file
oci os object get --bucket-name backups --name /accounting/accounting_backup_{year}_{month}_{day}.sql.gz --file /tmp/accounting_backup.sql.gz
# 3. Decompress the file
gunzip /tmp/accounting_backup.sql.gz
# 4. Restore accounting data
mysql --defaults-extra-file=/home/ubuntu/.billing.cnf billing < /tmp/accounting_backup.sql