{"id":16098621,"url":"https://github.com/funnyzak/mysql-onekey-backup","last_synced_at":"2026-05-17T17:04:03.809Z","repository":{"id":114592851,"uuid":"591334632","full_name":"funnyzak/mysql-onekey-backup","owner":"funnyzak","description":"A shell script to backup mysql database and send message with pushoo.","archived":false,"fork":false,"pushed_at":"2023-11-02T04:14:37.000Z","size":39,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-31T12:44:17.365Z","etag":null,"topics":["backup","mysql","mysql-backup","onekey-mysql-backup","pushoo-cli","shell"],"latest_commit_sha":null,"homepage":"http://dbback.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}},"created_at":"2023-01-20T14:03:57.000Z","updated_at":"2023-03-20T09:06:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"7d6cf8d6-ac8b-44c8-8d5a-f5989f7e7dd4","html_url":"https://github.com/funnyzak/mysql-onekey-backup","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/funnyzak/mysql-onekey-backup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fmysql-onekey-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fmysql-onekey-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fmysql-onekey-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fmysql-onekey-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funnyzak","download_url":"https://codeload.github.com/funnyzak/mysql-onekey-backup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnyzak%2Fmysql-onekey-backup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273122127,"owners_count":25049539,"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-09-01T02:00:09.058Z","response_time":120,"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":["backup","mysql","mysql-backup","onekey-mysql-backup","pushoo-cli","shell"],"created_at":"2024-10-09T18:24:10.512Z","updated_at":"2026-05-17T17:03:58.763Z","avatar_url":"https://github.com/funnyzak.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MySQL OneKey Backup\n\n[![GitHub license](https://img.shields.io/github/license/funnyzak/mysql-onekey-backup)](http://www.apache.org/licenses/LICENSE-2.0)\n[![GitHub stars](https://img.shields.io/github/stars/funnyzak/mysql-onekey-backup)](https://github.com/funnyzak/mysql-onekey-backup/stargazers)\n[![GitHub issues](https://img.shields.io/github/issues/funnyzak/mysql-onekey-backup)](https://github.com/funnyzak/mysql-onekey-backup/issues)\n[![GitHub forks](https://img.shields.io/github/forks/funnyzak/mysql-onekey-backup)](https://github.com/funnyzak/mysql-onekey-backup/network/members)\n[![Github Release](https://img.shields.io/github/release/funnyzak/mysql-onekey-backup)](https://github.com/funnyzak/mysql-onekey-backup/releases)\n\nA shell script to backup mysql database and send message with pushoo.\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 on CentOS 7+、Ubuntu 18.04+、Debian 9+.\n\n## Requirements\n\nYou need to install the following software before using the script.\n\n- mysqldump\n- pushoo-cli\n- nodejs 14+\n\nYou can install them with the following command.\n\n```bash\n# install mysqldump\nbash /path/to/mysql_backup.sh do_install_mysql_client\n\n# install pushoo-cli\nbash /path/to/mysql_backup.sh do_install_pushoo_cli\n\n# install nodejs 16\nbash /path/to/mysql_backup.sh do_install_nodejs\n```\n\nAttention: `You need config pushoo-cli before use it.`\n\n## Arguments\n\nThe script has 10 variables, you can set them in the script or pass them as arguments. following is the description of each variable.\n\n- `dump_target_dir` - The directory where the dump file will be saved. Default: `/path/to/db_backups`. Required.\n- `db_host` - The host of the database. Default: `127.0.0.1`. Required.\n- `db_user` - The user of the database. Default: `root`. Required.\n- `db_password` - The password of the database. Default is empty. Required.\n- `db_names` - The names of the database. If set empty, all databases will be backed up. Required.\n- `db_port` - The port of the database. Default: `3306`. Required.\n- `dump_opts` - The options of the mysqldump command. Default: `--single-transaction --quick --lock-tables=false`. Optional.\n- `expire_hours` - The dump file at the `specified directory` will be deleted after the specified number of hours. Default: `4320`. Optional.\n- `before_dump_command` - The command to be executed before the dump. Default is empty. Optional.\n- `after_dump_command` - The command to be executed after the dump. Default is empty. Optional.\n\nfor example:\n\n```bash\nbash mysql_backup.sh \"dump_target_dir\" \"db_host\" \"db_user\" \"db_password\" \"db_names\" db_port \"dump_opts\" expire_hours \"before_dump_command\" \"after_dump_command\"\n```\n\n## Usage\n\n```bash\n# backup \"db1\" and \"db2\" to \"/path/to/db_backups\" and the dump file will be deleted after 4320 hours.\nbash /path/to/mysql_backup.sh \"/path/to/db_backups\" \"127.0.0.1\" \"root\" \"examplepassword\" \"db1 db2\" 3306 \"--single-transaction --quick --lock-tables=false\" 4320\n# or\nbash /path/to/mysql_backup.sh \"/path/to/db_backups\" \"127.0.0.1\" \"root\" \"examplepassword\" \"db1 db2\"\n\n# backup \"db1\" and \"db2\" to \"/path/to/db_backups\" and the dump file will be deleted after 4320 hours. and log to /var/log/db_backup.log\nbash /path/to/mysql_backup.sh \"/path/to/db_backups\" \"127.0.0.1\" \"root\" \"examplepassword\" \"db1 db2\" \u003e\u003e /var/log/db_backup.log 2\u003e\u00261\n```\n\n## CronTab\n\nYou can use crontab to schedule the script to run periodically. For example, you can run the script every day at 3:00 AM.\n\n```bash\n0 3 * * * /path/to/mysql_backup.sh \"/path/to/db_backups\" \"127.0.0.1\" \"root\" \"examplepassword\" \"db1 db2\" \u003e\u003e /var/log/db_backup.log 2\u003e\u00261\n```\n\n## Docker\n\nYou can use docker image, [funnyzak/apline-cron](https://github.com/funnyzak/alpine-cron-docker) to schedule the script to run periodically.\n\n## Reference\n\n- [MySQL Command Line Client Installation Instructions](https://dev.mysql.com/doc/refman/8.0/en/mysql-installation.html)\n- [pushoo-cli](https://github.com/funnyzak/pushoo-cli) is a command line tool with Pushoo.js pushes multiple platform messages.\n- [Pushoo.js](https://github.com/imaegoo/pushoo)\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/mysql-onekey-backup/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=funnyzak/mysql-onekey-backup\" /\u003e\n\u003c/a\u003e\n\n## License\n\nMIT License © 2023 [funnyzak](https://github.com/funnyzak)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnyzak%2Fmysql-onekey-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunnyzak%2Fmysql-onekey-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnyzak%2Fmysql-onekey-backup/lists"}