Barebones backup script for MariaDB with Discord Webhook notifications. Allows you to run a cron / task schedule of program to automatically backup, compress, encrypt and upload your database to Amazon S3.
Requirements:
- Python 3.10+
- MariaDB CLI with mariabackup
- 7-Zip CLI
- OpenSSL CLI
Commands:
run.bat- Run the script.
Install:
Important
Your sensitive credentials should ideally be properly stored somewhere, ideally a vault or at worst, environment variables as shown in the program. AWS also provides secure id/key storage.
- Install Requirements.
- Configure
config.ymland set upBU_DB_PASSWORDenv variable. - Set secure
BU_ENC_PASSPHRASEenv var, which will serve as encryption key. - Configure or remove
--tables-excludevar to your liking (using this to exclude multi-GB of logs for personal usecase). - Follow
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html#using-environment-variablesto set up AWS credentials. python -m venv venvcall venv\Scripts\activate.batpip install -r requirements.txt- Configure
run.bat - Run / apply
run.baton a schedule / manual basis
- Download
.xb.gz.encfile from S3 and put in folder - Create subfolder which will host your restored content
- Run OpenSSL command in root folder
openssl enc -d -aes-256-cbc -in <yourencbackup>.xb.gz.enc -out <unencbackup>.xb.gz -k BU_ENC_PASSPHRASE - Decompress
.xb.gzfile, you should now have a raw.xbfile. - Run
mbstream -x < <unencbackup>.xb --directory=<yoursubfolder> - The xb file should now be unpacked in the restored content folder.
- Prep this folder using
mariabackup --prepare --target-dir=<yoursubfolder> - Copyback contents of subfolder to your new MariaDB instance
mariabackup --copy-back --target-dir=<yoursubfolder> - Any issues, consult MariaBackup Docs