The mysql-backup Docker image will provide you a container to backup and restore a MySQL or MariaDB database container.
The backup is made with mydumper, a fast MySQL backup utility.
To backup a MySQL or MariaDB container you simply have to run a container from this Docker image and link a MySQL or MariaDB container to it.
The container will use database, specified by environment variables
Please note the backup will be written to /backup by default, so you might want to mount that directory from your host.
To create a backup from a MySQL container via docker CLI client:
docker run --name my-backup --link my-mysql -v /var/mysql_backups:/backup confirm/mysql-backup
The container will stop automatically as soon as the backup has finished. To create more backups in the future simply start your container again:
docker start my-backup
To restore a backup into a MySQL container via docker CLI client:
docker run --name my-restore --link my-mysql -v /var/mysql_backups:/backup confirm/mysql-backup
Here's an example of a Docker Compose file, e.g. docker-compose.yml:
backup:
image: confirm/mysql-backup
volumes:
- ./data/backup:/backup
links:
- my-mysql
restart: never
By default the container backups the database. However, you can change the mode of the container by setting the following environment variable:
MODE: Sets the mode of the backup container while [BACKUP|RESTORE]By default the base directory /backup is used.
However, you can overwrite that by setting the following environment variable:
BASE_DIR: Path of the base directory (aka working directory)By default the container will automatically restore the latest backup found in BASE_DIR.
However, you can manually set the name of a backup directory underneath BASE_DIR:
RESTORE_DIR: Name of a backup directory to restoreThis option is only required when the container runs in in RESTORE mode.
By default the backup will be written with UID and GID 666.
However, you can overwrite that by setting the following environment variables:
BACKUP_UID: UID of the backupBACKUP_GID: GID of the backupBy default a umask of 0022 will be used.
However, you can overwrite that by setting the following environment variable:
UMASK: Umask which should be used to write the backup filesBy default mydumper is invoked with the -c (compress backup) and myloader with the -o (overwrite tables) CLI option.
However, you can modify the CLI options by setting the following environment variable:
OPTIONS: Options passed to mydumper (when MODE is BACKUP) or myloader (when MODE is RESTORE)Content type
Image
Digest
Size
111.2 MB
Last updated
about 5 years ago
docker pull itherz/mysql-backup:0.10.7