Public | Automated Build

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description

Docker-MySQL-Cloud-Backup

This is a tool to automate daily dump backups and restores of MySQL instances running inside Docker containers to cloud storage. With only one command, this tool takes a backup from a MySQL container using mysqldump, compresses it, encrypts it and uploads it to Rackspace Cloud Files using turbolift. For restore, dumps are downloaded from Rackspace, decrypted, unpacked and re-imported into a new MySQL container with the mysql command. The tool itself is delivered as a Docker container and thus requires no external dependencies.

Configuration

Configuration is set with environment variables. The following variables are mandatory:

  • CLOUD_USER: The Rackspace username used for access to Cloud Files.
  • CLOUD_KEY: The Rackspace API key used for access to Cloud Files.
  • DB_USER: The MySQL username for the database container.
  • DB_PASSWORD: The MySQL password for the database container.
  • ENC_KEY: A string that is used to encrypt or decrypt the backup. The same key must be specified for backup and restore.

The following variables are optional:

  • MYSQLDUMP_PARAMETERS: Specifies additional parameters to be given to mysqldump. For example, if the backup is used to set up a replication slave, -e MYSQLDUMP_PARAMETERS="--master-data" cloud be given. For backup only, ignored for restore.
  • RETAIN_DAYS: Specifies the number of days that daily backups should be kept. If this parameter is given, the backup that was created RETAIN_DAYS ago will be deleted after the current backup has been created. For backup only, ignored for restore.

The container from which the backup should be taken or into which the backup should be restored needs to be linked with the alias mysql.

Commands to Run

Backup

docker run --rm --link={mysql-container-name}:mysql \
  -e CLOUD_USER={username} -e CLOUD_KEY={api-key} \
  -e DB_USER={username} -e DB_PASSWORD={password} -e ENC_KEY={encryption-key} \
  jadoos/mysql-cloud-backup backup {database1} {database2} {...}

Restore

docker run --rm --link={mysql-container-name}:mysql \
  -e CLOUD_USER={username} -e CLOUD_KEY={api-key} \
  -e DB_USER={username} -e DB_PASSWORD={password} -e ENC_KEY={encryption-key} \
  jadoos/mysql-cloud-backup restore {YYYYMMDD} {database1} {database2} {...}

A prior installation is not required as Docker automatically downloads the latest image from the Docker hub if it does not exist on the host system.

Docker Pull Command
Owner
jadoos