The docker-mysql-backup image is meant to be run alongside a deployment that features a mysql/mariadb container that needs to be backed up.
The backup is performed using mydumper, a fast MySQL backup utility.
Add a service to your docker-compose file like so:
version: '2' volumes: db-data: services: mysql: image: mysql volumes: - db-data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD - MYSQL_DATABASE - MYSQL_USER - MYSQL_PASSWORD restart: unless-stopped ports: - 3406:3306 backup: image: nikosch86/docker-mysql-backup:develop volumes: - ./data/backup:/backup environment: - MYSQL_ROOT_PASSWORD
as you can see it is best practice to store your mysql secrets in a .env file, so both containers have access to it
the minimal viable configuration just needs the root password, it will backup all databases and look for a container named
mysql on port
be aware, the backup container will create the folder
/backup and use
GID 1000 to own it.
That means any folder mounted to the
/backup location will be affected by that.
additional configuration can be done by using these environment variables:
BASE_DIR is the directory the backups will be written to inside the container.
OPTIONS will override the options set for
The container will stop automatically as soon as the backup is done.
To start backing up you need to start the container.
docker-compose up -d backup
To restore a backup, the environment variable
MODE needs to be set to
RESTORE_DIR needs to be set to the directory of your backup
Starting the container will use
myload to restore the specified backup into the
specified container and database