{"id":20651417,"url":"https://github.com/mirocow/mysql_utils","last_synced_at":"2025-04-17T13:42:37.214Z","repository":{"id":8907766,"uuid":"10631988","full_name":"Mirocow/mysql_utils","owner":"Mirocow","description":"Backup and Restore data from MySql tables","archived":false,"fork":false,"pushed_at":"2024-02-20T12:25:12.000Z","size":237,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T06:11:23.529Z","etag":null,"topics":["backup","databases","mysql-tables","mysql-utility","mysql-utils","restore","restore-data"],"latest_commit_sha":null,"homepage":"http://mirocow.com","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mirocow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2013-06-11T22:10:38.000Z","updated_at":"2023-08-22T17:29:39.000Z","dependencies_parsed_at":"2024-02-20T13:45:07.311Z","dependency_job_id":null,"html_url":"https://github.com/Mirocow/mysql_utils","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mirocow%2Fmysql_utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mirocow%2Fmysql_utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mirocow%2Fmysql_utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mirocow%2Fmysql_utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mirocow","download_url":"https://codeload.github.com/Mirocow/mysql_utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249345663,"owners_count":21254900,"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","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","databases","mysql-tables","mysql-utility","mysql-utils","restore","restore-data"],"created_at":"2024-11-16T17:27:22.406Z","updated_at":"2025-04-17T13:42:37.196Z","avatar_url":"https://github.com/Mirocow.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## mysql_utils for Debian or Other OS\n\nBackup and Restore data from MySql tables\n\n### Install\n\n```bash\n$ cd ~\n$ git clone https://github.com/Mirocow/mysql_utils.git\n$ cd mysql_utils\n```\n\nnano /etc/mysql/mysql.conf.d/mysqld.cnf\n```\n[mysqld]\nsecure-file-priv = \"\"\n```\n\nnano /lib/systemd/system/mysql.service\n```\n[Service]\nPrivateTmp=false\n```\n\n```bash\n$ systemctl daemon-reload\n```\n\n### Backup all databases\n\n```bash\n$ cd ~\n$ cd mysql_utils\n$ bash backup.sh\n```\n\n### Backup selected database\n\n```bash\n$ cd ~\n$ cd mysql_utils\n$ bash backup_db.sh \u003c[database-name]\u003e\n```\n\n### Restore for selected date\n\n```bash\n$ cd /var/backups/mysql/[some date]\n$ bash ~/mysql_utils/restore.sh\n```\n\n### Restore selected DB\n\n```bash\n$ cd /var/backups/mysql/[some date]/[some db name]\n$ bash ~/mysql_utils/restore_db.sh\n```\n\n### Automation backup with Cron\n\nnano /etc/default/db_backup\n```\n    START=yes\n```\n\nnano /etc/cron.daily/db_backup\n```\n    #!/bin/sh\n\n    . /etc/default/db_backup\n\n    if [ \"$START\" = \"yes\" ]; then\n    \tlogger \"Start databases backup system...\"\n    \t/bin/bash /root/scripts/mysql_utils/backup.sh --e=\"some_exclude_database some_else_db\"\n    fi\n```\n\n### Check work\n\n```\n    # tail -f /var/log/syslog\n        May 23 12:25:34 db1 logger: BACKUP:   ** Dump tecdoc.2013.ALI_COORD\n        May 23 12:25:35 db1 logger: BACKUP:   ** set permision to tecdoc.2013/AL\n        May 23 12:25:35 db1 logger: BACKUP:   ** bzip2 tecdoc.2013/ALI_COOR\n        May 23 12:25:35 db1 logger: BACKUP:   ** Dump tecdoc.2013.ARTICLES\n        May 23 12:25:43 db1 logger: BACKUP:   ** set permision to tecdoc.2013/AR\n        May 23 12:25:43 db1 logger: BACKUP:   ** bzip2 tecdoc.2013/ARTICLES\n        May 23 12:25:43 db1 logger: BACKUP:   ** Dump tecdoc.2013.ARTICLES_\n        May 23 12:25:43 db1 logger: BACKUP:   ** set permision to tecdoc.2013/AR\n        May 23 12:25:43 db1 logger: BACKUP:   ** bzip2 tecdoc.2013/ARTICLES\n        May 23 12:25:43 db1 logger: BACKUP:   ** Dump tecdoc.2013.ARTICLE_C\n```\n\n### Tested on\n\n* Debiad\n* FreeBsd\n* Ubuntu\n\n### Help\n\n``` sh\n# bash backup.sh --help\nusage: backup.sh options\n\nThis script buckup all databases.\n\nUsage: backup.sh \u003c[options]\u003e\n\nOptions:\n   -e= | --exclude=                     Exclude databases\n   --exclude-tables=                    Exclude tables\n   -c= | --compress=                    Compress with gzip or bzip2\n   -v  | --verbose                      Add verbose into output\n   -l  | --lifetime=                    Lifetime for dump files\n   --config=                            Config file of Debian format\n   --dir=                               Backup directory\n   -h  | --help                         This text\n\nExamples:\n        backup.sh --verbose --compress=\n        backup.sh --verbose --compress=gzip\n        backup.sh --verbose --compress=bzip2\n        backup.sh --verbose --compress= --exclude=\"mysql\"\n        backup.sh --verbose --compress= --exclude=\"mysql\" --lifetime=\"3 day ago\"\n        backup.sh --verbose --config=\"/etc/mysql/debian.cnf\" --exclude=\"mysql\" --lifetime=\"1 day ago\"\n        backup.sh --verbose --dir=\"/var/backups/mysql\" --config=\"/etc/mysql/debian.cnf\" --exclude=\"mysql\" --lifetime=\"1 day ago\"\n        backup.sh --verbose --dir=\"/home/backups/mysql\" --exclude=\"mysql\" --lifetime=\"1 day ago\"\n        backup.sh --verbose --dir=\"/home/backups/mysql\" --exclude=\"mysql\" --exclude-tables=\"tbl_template\" --lifetime=\"1 day ago\"\n```\n\n#### Errors\n\n* The MySQL server is running with the --secure-file-priv option so it cannot execute this statement when executing 'SELECT INTO OUTFILE\n```\n[mysqld]\nsecure-file-priv = \"\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirocow%2Fmysql_utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirocow%2Fmysql_utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirocow%2Fmysql_utils/lists"}