{"id":16098625,"url":"https://github.com/funnyzak/mysql-backup-docker","last_synced_at":"2025-08-18T08:05:56.078Z","repository":{"id":114592819,"uuid":"262542915","full_name":"funnyzak/mysql-backup-docker","owner":"funnyzak","description":"This is a docker image for MySQL backup. It is based on Alpine Linux and uses MySQL Client and MySQLDUMP to dump your database.","archived":false,"fork":false,"pushed_at":"2024-10-30T10:35:25.000Z","size":60,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-02T12:05:10.420Z","etag":null,"topics":["autobackup","backup","docker","docker-image","mysql","mysql-backup","mysqlbackup"],"latest_commit_sha":null,"homepage":"https://mysql-backup.gp.yycc.dev","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/funnyzak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-05-09T10:09:22.000Z","updated_at":"2024-10-30T10:36:29.000Z","dependencies_parsed_at":"2025-06-18T18:41:04.806Z","dependency_job_id":"6a67edb4-0cd1-45b2-a7e3-24005f89604a","html_url":"https://github.com/funnyzak/mysql-backup-docker","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/funnyzak/mysql-backup-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fmysql-backup-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fmysql-backup-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fmysql-backup-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fmysql-backup-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funnyzak","download_url":"https://codeload.github.com/funnyzak/mysql-backup-docker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fmysql-backup-docker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268629550,"owners_count":24281170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autobackup","backup","docker","docker-image","mysql","mysql-backup","mysqlbackup"],"created_at":"2024-10-09T18:24:10.945Z","updated_at":"2025-08-03T23:39:04.711Z","avatar_url":"https://github.com/funnyzak.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MySQL backup Docker\n\n[![Build Status][build-status-image]][build-status]\n[![Docker Stars][docker-star-image]][repository-url]\n[![Docker Pulls][docker-pull-image]][repository-url]\n[![GitHub release (latest by date)][latest-release]][repository-url]\n[![GitHub][license-image]][repository-url]\n\nThis is a docker image for MySQL backup. It is based on Alpine Linux and uses [MySQL Client](https://www.mysql.com/) and [MySQLDUMP](https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html) to dump your database.\n\nDownload size of this image is:\n\n[![Image Size][docker-image-size]][docker-hub-url]\n\n[Docker hub image: funnyzak/mysql-backup][docker-hub-url]\n\n**Docker Pull Command**: `docker pull funnyzak/mysql-backup:latest`\n\nAttention: Current version is not compatible old version, please use tag `0.1.1` if you want to use old version.\n\n## Features\n\n- Backup all databases or specified databases.\n- Push message with pushoo.\n- Delete expired dump files.\n- Support custom commands before and after the dump.\n- Support custom mysqldump options.\n- Support compressed dump files.\n- Support crontab rules.\n\n## Configuration\n\nThe following environment variables are used to configure the container:\n\n### Required\n\nThe following environment variables are required:\n\n- `DB_DUMP_CRON` - The crontab rule of backup. Default: `0 0 * * *`. Optional.\n- `DB_HOST` - The database host. Required.\n- `DB_PORT` - The database port. Default: `3306`.\n- `DB_USER` - The database user. Required.\n- `DB_PASSWORD` - The database password. Required.\n- `DB_NAMES` - The database name of the dump.For example: dbname1 dbname2.Leave a blank default to all databases.\n- `DUMP_OPTS` - The mysqldump options. Optional. Default: `--single-transaction --quick --lock-tables=false`.\n- `EXPIRE_HOURS` - The expired time of the dump files. Default: `4320`.\n\n### Optional\n\nThe following environment variables are optional:\n\n- `DUMP_AT_STARTUP` - Whether to dump at startup. Default: `true`.\n- `DB_DUMP_TARGET_DIR_PATH` - The directory path to store the dump files. Default: `/backup`.\n- `TMP_DIR_PATH` - The directory path to store the temporary files. Default: `/tmp/backups`.\n- `DB_DUMP_BY_SCHEMA` - Whether to use separate files for each schema in the compressed file (true), if so, you need to set DB_NAMES. Or single dump file (FALSE). Default: `true`.\n- `DB_FILE_EXTENSION` - The dump file extension. Default: `sql`.\n- `COMPRESS_EXTENSION` - The compress file extension. Default: `zip`.\n- `STARTUP_COMMAND` - The command to execute at startup. Optional.\n- `BEFORE_DUMP_COMMAND` - The command to execute before the dump. Optional.\n- `AFTER_DUMP_COMMAND` - The command to execute after the dump. Optional.\n\n### Pushoo\n\nIf you want to receive message with pushoo, you need to set `PUSHOO_PUSH_PLATFORMS` and `PUSHOO_PUSH_TOKENS`.\n\n- `SERVER_NAME` - The server name, used for pushoo message. Optional.\n- `PUSHOO_PUSH_PLATFORMS` - The push platforms, separated by commas. Optional.\n- `PUSHOO_PUSH_TOKENS` - The push tokens, separated by commas. Optional.\n\nFor more details, please refer to [pushoo-cli](https://github.com/funnyzak/pushoo-cli).\n\n## Usage\n\n### Simple\n\nFor example, you want to backup database `dbname1` and `dbname2` every day at 00:00, and delete expired dump files after 180 days.\n\n```bash\ndocker run -d --name mysql-backup \\\n  -e DB_DUMP_CRON=\"0 0 * * *\" \\\n  -e DB_HOST=\"localhost\" \\\n  -e DB_PORT=3306 \\\n  -e DB_USER=\"root\" \\\n  -e DB_PASSWORD=\"root\" \\\n  -e DB_NAMES=\"dbname1 dbname2\" \\\n  -e DB_DUMP_OPTS=\"--single-transaction --quick --lock-tables=false\" \\\n  -e EXPIRE_HOURS=4320 \\\n```\n\n### Compose\n\nFor example, you want to backup database `cms_new` every day at 00:00, and delete expired dump files after 180 days.\n\n```yaml\nversion: '3'\nservices:\n  dbback:\n    image: funnyzak/mysql-backup\n    privileged: false\n    container_name: app-db-backup\n    tty: true\n    mem_limit: 1024m\n    environment:\n        - TZ=Asia/Shanghai\n        - LANG=C.UTF-8\n        # Cron\n        - DB_DUMP_CRON=0 0 * * *\n        # MySQL Connection\n        - DB_HOST=192.168.50.21\n        - DB_NAMES=cms_new\n        - DB_USER=root\n        - DB_PASSWORD=helloworld\n        - DB_PORT=1009\n        - DUMP_OPTS=--single-transaction\n        # Expire Hours\n        - EXPIRE_HOURS=4320\n        # COMMAND\n        - STARTUP_COMMAND=echo \"startup\"\n        - BEFORE_DUMP_COMMAND=echo \"before dump\"\n        - AFTER_DUMP_COMMAND=echo \"after dump\"\n        # optional\n        - DB_DUMP_TARGET_DIR_PATH=/backup\n        - DB_DUMP_BY_SCHEMA=true\n        - DB_FILE_EXTENSION=sql\n        - COMPRESS_EXTENSION=zip\n        - DUMP_AT_STARTUP=true\n        # pushoo \n        - SERVER_NAME=app-db-backup\n        - PUSHOO_PUSH_PLATFORMS=dingtalk,bark\n        - PUSHOO_PUSH_TOKENS=dingtalk:xxxx,bark:xxxx\n    restart: on-failure\n    volumes:\n      - ./bak/mysql_db:/backup\n```\n\nFor more details, please refer to the [docker-compose.yml](example/docker-compose.yml) file.\n\n## Contribution\n\nIf you have any questions or suggestions, please feel free to submit an issue or pull request.\n\n\u003ca href=\"https://github.com/funnyzak/vue-starter/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=funnyzak/mysql-backup-docker\" /\u003e\n\u003c/a\u003e\n\n## License\n\nMIT License © 2022 [funnyzak](https://github.com/funnyzak)\n\n[build-status-image]: https://github.com/funnyzak/mysql-backup-docker/actions/workflows/build.yml/badge.svg\n[build-status]: https://github.com/funnyzak/mysql-backup-docker/actions\n[repository-url]: https://github.com/funnyzak/mysql-backup-docker\n[license-image]: https://img.shields.io/github/license/funnyzak/mysql-backup-docker?style=flat-square\u0026logo=github\u0026logoColor=white\u0026label=license\n[latest-release]: https://img.shields.io/github/v/release/funnyzak/mysql-backup-docker\n[docker-star-image]: https://img.shields.io/docker/stars/funnyzak/mysql-backup.svg?style=flat-square\n[docker-pull-image]: https://img.shields.io/docker/pulls/funnyzak/mysql-backup.svg?style=flat-square\n[docker-image-size]: https://img.shields.io/docker/image-size/funnyzak/mysql-backup\n[docker-hub-url]: https://hub.docker.com/r/funnyzak/mysql-backup\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnyzak%2Fmysql-backup-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunnyzak%2Fmysql-backup-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnyzak%2Fmysql-backup-docker/lists"}