This docker image runs mysqldump to backup your databases periodically using cron task manager. Backups are placed in /backup so you can mount your backup docker volume in this path.
docker run -d \
--env MYSQL_USER=root \
--env MYSQL_PASS=xx \
--env MYSQL_HOST=xx \
--env INIT_BACKUP=100 \
--env ALIYUN_ENDPOINT=xx \
--env ALIYUN_ID=xxx \
--env ALIYUN_SECRET=xx \
--env ALIYUN_DEST=bucket-name/mysql \
-v /backup:/backup \
--name mysqlbackup zengsuyi/mysql-oss-backup:1.0
ALIYUN_ENDPOINT: aliyun oss endpointALIYUN_ID: aliyun accessKeyIdALIYUN_SECRET: aliyun accessKeySecretALIYUN_DEST: aliyun oss Bucket name and dir. bucket-name/destMYSQL_HOST: The host/ip of your mysql database.MYSQL_PORT: The port number of your mysql database.MYSQL_USER: The username of your mysql database.MYSQL_PASS: The password of your mysql database.MYSQL_DB: The database name to dump. Default: --all-databases.MYSQLDUMP_OPTS: Command line arguments to pass to mysqldump. Example: --single-transaction.CRON_TIME: The interval of cron job to run mysqldump. 0 3 * * sun by default, which is every Sunday at 03:00. It uses UTC timezone.MAX_BACKUPS: The number of backups to keep. When reaching the limit, the old backup will be discarded. No limit by default.INIT_BACKUP: If set, create a backup when the container starts.INIT_RESTORE_LATEST: If set, restores latest backup.TIMEOUT: Wait a given number of seconds for the database to be ready and make the first backup, 10s by default. After that time, the initial attempt for backup gives up and only the Cron job will try to make a backup.GZIP_LEVEL: Specify the level of gzip compression from 1 (quickest, least compressed) to 9 (slowest, most compressed), default is 6.See the list of backups in your running docker container, just write in your favorite terminal:
docker exec backup ls /backup
To restore a database from a certain backup, simply run:
docker exec backup /restore.sh /backup/201708060500.my_db.sql.gz
Content type
Image
Digest
Size
26.3 MB
Last updated
almost 6 years ago
docker pull zengsuyi/mysql-oss-backup:1.0