Minimal container to backup MySQL/MariaDB, Redis, and SQLite
3.1K
This project started to have a simple and lightweight container to :
All of this inside Docker containers for portable purposes.
This containers is powered up by Kubernetes
To work properly, the scripts will require informations and credentials
We assume they are passed to the container in ENV
MySQL/MariaDB server related variables :
DBLIST: is a list, representing the DB to backupDB_HOST: mysql-server hostname or IPDB_PORT: mysql-server portDB_USER: mysql-server usernameDB_PASS: mysql-server passwordSQLite server related variables :
SQLITE: boolean, to switch to this backup typeSQLITE_FILE: sqlite database filename (ex: sqlite3.db)SQLITE_PATH: sqlite database location (ex: /db)In my case I use a rsync enabled remote storage called PCA (Public Cloud Archive), hence the variable names
PCA_USER: destination rsync usernamePCA_PASS: destination rsync passwordPCA_HOST: destination rsync hostPCA_DIR: destination direcory to store the backupsMySQL/MariaDB version
2020-10-23 12:36:00 [hourly] my-mysql-server/my-database
2020-10-23 12:36:00 [hourly] └> Dumping [✓]
2020-10-23 12:36:00 [hourly] └> Zipping [✓]
2020-10-23 12:36:00 [hourly] └> Sending [✓]
2020-10-23 12:36:00 [hourly] └> Cleaning [✓]
2020-10-23 12:36:03 [hourly] my-mysql-server/mysql
2020-10-23 12:36:03 [hourly] └> Dumping [✓]
2020-10-23 12:36:03 [hourly] └> Zipping [✓]
2020-10-23 12:36:03 [hourly] └> Sending [✓]
2020-10-23 12:36:03 [hourly] └> Cleaning [✓]
SQLite version
2020-10-27 14:57:43 [hourly] /db/nacridan.db
2020-10-27 14:57:43 [hourly] └> Dumping [✓]
2020-10-27 14:57:43 [hourly] └> Zipping [✓]
2020-10-27 14:57:43 [hourly] └> Sending [✓]
2020-10-27 14:57:43 [hourly] └> Cleaning [✓]
Once a day, a status will be displayed with Size used & number of zip files
2020-10-23 15:21:05 ========== Remote Disk Usage Status ==========
2020-10-23 15:21:05 [hourly] Size: 22 MB (Zip-files: 48)
2020-10-23 15:21:07 [daily] Size: 29 MB (Zip-files: 62)
2020-10-23 15:21:10 [weekly] Size: 11 MB (Zip-files: 27)
2020-10-23 15:21:12 [monthly] Size: 3 MB (Zip-files: 8)
2020-10-23 15:21:12 ==============================================
On the remote storage PCA_HOST,
the backups are stored in PCA_DIR are stored this way :
.
└── PCA_DIR
├── daily
│ └── $(date +%d)-dump-$(dbname).SQL.zip
├── hourly
│ └── $(date +%H)-dump-$(dbname).SQL.zip
├── monthly
│ └── $(date +%B)-dump-$(dbname).SQL.zip
└── weekly
└── $(date +%W)-dump-$(dbname).SQL.zip
I used mainy :
And of course GitHub to store all these shenanigans.
You can build the container yourself :
$ git clone https://github.com/lordslair/easydbbackup
$ cd docker
$ docker build .
Or the latest build is available on docker hub :
# docker pull lordslair/easydbbackup
Using default tag: latest
latest: Pulling from lordslair/easydbbackup
Digest: sha256:20a216bc9c9e5bbea2a64f1ef152ee8874dcdec5faec6a9ccfab70cb0e1c1ba7
Status: Downloaded newer image for lordslair/easydbbackup:latest
For a Kubernetes (k8s) deployment with MySQL/MariaDB, I added examples files :
Of course, you'll have to modify the secrets to fit with your credentials
$ git clone https://github.com/lordslair/easydbbackup
$ cd easydbbackup/k8s
$ kubectl apply -f secrets.yaml
$ kubectl apply -f deployment.yaml
For a Kubernetes (k8s) deployment with SQLite, I added examples files :
Of course, you'll have to modify the env vars to fit with your credentials
$ git clone https://github.com/lordslair/easydbbackup
$ cd easydbbackup/k8s
$ kubectl apply -f deployment-sqlite.yaml
Always double-check your backups and test the restoration process once in a while.
I won't take the blame =)
Content type
Image
Digest
sha256:d8be45c0e…
Size
83 MB
Last updated
10 months ago
docker pull lordslair/easydbbackup