Creating and managing scheduled MySQL backups at non-root container with AutoMySQLBackup utility.
835
A lightweight, Alpine linux based image for creating and managing scheduled MySQL backups at non-root container. Runs a slightly modified AutoMySQLBackup utility.
Forked from and modify for Openshift (non-container root).
| Tag | Info | Badges |
|---|---|---|
| latest: | alpine version | |
| develop: | alpine version | |
| alpine: | without MySQL 8 support | |
| debian: | with MySQL 8 support |
This image uses AutoMySQLBackup 2.5 from Debian Linux source repository as a base, branched at 2.6+debian.4-1 tag.
Original source can be cloned from git://anonscm.debian.org/users/zigo/automysqlbackup.git or taken at the
appropriate Debian package page.
Custom modifications:
Currently it is not possible to use this image with the default configuration of MySQL 8. Alpine linux comes with MariaDB's version of mysqldump which doesn't support newly introduced caching_sha2_password authentication method.
As a workaround you can either completely switch mysqld to an old authentication
method with default-authentication-plugin=mysql_native_password option or
change authentication method for a specific user:
ALTER USER 'username' IDENTIFIED WITH mysql_native_password BY 'password';
Let's create a bridge network and start a MySQL container as an example.
docker network create dbtest
docker run --name some-mysql --network dbtest \
-e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest
For the basic one-shot backup, you can run a container like this:
docker run --network dbtest \
-v '/var/lib/automysqlbackup:/backup' \
-e DBHOST=some-mysql \
-e DBNAMES=all \
-e USERNAME=root \
-e PASSWORD=my-secret-pw \
-e DBNAMES=all \
jorgeandrada/openshift-automysqlbackup:alpine
Container will create dumps of all datebases from MySQL inside /var/lib/automysqlbackup directory and exit.
To run container in a scheduled mode, populate CRON_SCHEDULE environment variable with a cron expression.
docker run --network dbtest \
-v '/var/lib/automysqlbackup:/backup' \
-e DBHOST=some-mysql \
-e DBNAMES=all \
-e USERNAME=root \
-e PASSWORD=my-secret-pw \
-e DBNAMES=all \
-e CRON_SCHEDULE="0 0 * * *" \
jorgeandrada/openshift-automysqlbackup:alpine
Instead of passing environment variables though docker, you can also mount a file with their declarations
as volume. See defaults file in this image's git repository for the example.
docker run --network dbtest \
-v '/var/lib/automysqlbackup:/backup' \
-v '/etc/default/automysqlbackup:/etc/default/automysqlbackup:ro' \
jorgeandrada/openshift-automysqlbackup:alpine
For the example of using this image with docker-compose, see docker-compose.yml file in the image's repository.
Quick tips:
automysqlbackup binary directly for the manual backup: docker-compose exec mysqlbackup automysqlbackupCRON_SCHEDULE: "0 0 * * *"
as YAML sequence - CRON_SCHEDULE="0 * * * *" will preserve quotes breaking go-cron (Issue #1).If set to cron expression, container will start a cron daemon for scheduled backups.
Username to access the MySQL server.
Password to access the MySQL server.
Host name (or IP address) of MySQL server.
Port of MySQL server.
List of space separated database names for Daily/Weekly Backup. Set to all for all databases.
Default value: all
Backup directory location. Folders inside this one will be created (daily, weekly, etc.), and the subfolders will be database names.
Default value: /backup
List of space separated database names for Monthly Backups.
Will mirror DBNAMES if DBNAMES set to all.
List of DBNAMES to exclude if DBNAMES are set to all (must be in " quotes).
Include CREATE DATABASE in backup?
Default value: yes
Separate backup directory and file for each DB? (yes or no).
Default value: yes
Which day do you want weekly backups? (1 to 7 where 1 is Monday).
Default value: 6
Choose Compression type. (gzip or bzip2)
Default value: gzip
Compress communications between backup server and MySQL server?
Default value: no
Additionally keep a copy of the most recent backup in a seperate directory.
Default value: no
The maximum size of the buffer for client/server communication. e.g. 16MB (maximum is 1GB)
For connections to localhost. Sometimes the Unix socket file must be specified.
Command to run before backups
Command run after backups
Backup of stored procedures and routines
Default value: yes
Similar to the original automysqlbackup script, all sources for this image are licensed under GPL-2.0.
Content type
Image
Digest
Size
14.3 MB
Last updated
over 7 years ago
docker pull jorgeandrada/openshift-automysqlbackup