{"id":14969098,"url":"https://github.com/torstein-eide/backupmysql","last_synced_at":"2026-02-05T10:08:41.888Z","repository":{"id":133990038,"uuid":"140984255","full_name":"Torstein-Eide/backupMysql","owner":"Torstein-Eide","description":"Scripts for backing up mysql server","archived":false,"fork":false,"pushed_at":"2024-05-12T19:23:04.000Z","size":59,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T22:32:13.841Z","etag":null,"topics":["backup","database","mariadb","mariadb-server","mysql","mysql-server","tar"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Torstein-Eide.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}},"created_at":"2018-07-14T23:18:44.000Z","updated_at":"2024-05-12T19:23:07.000Z","dependencies_parsed_at":"2024-01-23T18:07:15.184Z","dependency_job_id":"fdb70c4b-f6a5-45e3-ad89-6f9b2863afb1","html_url":"https://github.com/Torstein-Eide/backupMysql","commit_stats":{"total_commits":52,"total_committers":6,"mean_commits":8.666666666666666,"dds":0.25,"last_synced_commit":"117decedea0cbd0460d27b062e012ff4dd0a6faa"},"previous_names":["torstein-eide/backupmysql"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torstein-Eide%2FbackupMysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torstein-Eide%2FbackupMysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torstein-Eide%2FbackupMysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torstein-Eide%2FbackupMysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Torstein-Eide","download_url":"https://codeload.github.com/Torstein-Eide/backupMysql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241367932,"owners_count":19951444,"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","database","mariadb","mariadb-server","mysql","mysql-server","tar"],"created_at":"2024-09-24T13:41:07.493Z","updated_at":"2026-02-05T10:08:41.816Z","avatar_url":"https://github.com/Torstein-Eide.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# backup of mysql/mariadb\nnote: this script runs unsecured connection, so don't use it over the internet.\n\n## get the scripts:\n```\ninstall -d /etc/scripts\n\ncd /etc/scripts\nwget https://raw.githubusercontent.com/Eideen/backupMysql/master/db_backup_daily.sh\nwget https://raw.githubusercontent.com/Eideen/backupMysql/master/db_backup_common.sh\nwget https://raw.githubusercontent.com/Eideen/backupMysql/master/db_backup_horly.sh\nchmod +x ./db_backup*.sh\nchmod 700 ./db_backup_common.sh\n```\n## make a backup user:\n* HOSTNAME\nServer that the script is running on.\n* DB_USERNAME\ndatabase backup username\n* DB_PASSWORD\ndatabase backup user passowrd, make a random password.\n\n### A way to make a password:\n```\ndate +%s | sha256sum | base64 | head -c 32 ; echo\n```\n## On the mysql server:\n\nOpen Maria/Mysql program, with admin privlages.\n```\nmariadb -u root\n```\n\nRun sql commands.\n```sql\nCREATE USER '${DB_USERNAME}'@'Localhost' IDENTIFIED BY '${DB_PASSWORD}';\nGRANT LOCK TABLES, SELECT, SHOW VIEW, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER ON *.* TO '${DB_USERNAME}'@'Localhost' ;\nflush privileges;\n```\n## edit the scripts to fit your setup:\n* DB_USERNAME\ndatabase backup username, it is recommend to use a dedicated backup user.\n* DB_PASSWORD\ndatabase backup user passowrd\n* DB_HOSTNAME\ndatabase backup hostname\n* DEST\npath you wanted to save the backup\n* TEMPdir\npath to temporary store datebase files before \n* EMAIL\nyour mail, if you wanted to send mail to you. you also need to make sure you have setup `ssmtp`.\n* DAYS \nNumber of days to save.\n* SKIP\nDatabases to skip.\ndefault is `information_schema` and `performance_schema`. One line per datebase.\n```\nNano db_backup_horly.sh db_backup_daily.sh\n```\n\n## Now test your script:\n```\n/etc/scripts/db_backup_horly.sh\n/etc/scripts/db_backup_daily.sh\n```\noutput example:\n\u003e```\n\u003elist of databases:\n\u003e* information_schema\n\u003e* mysql\n\u003e* performance_schema\n\u003efolder /volum/@backup/mysql/daglig exist\n\u003eskiping   information_schema\n\u003eskiping   performance_schema\n\u003eextracted mysql in 0 cpu seconds\n\u003email not setup\n\u003eMySQL backup is completed without export fail\n\n## you can control the content of the backup with the following commands:\n ```\n tar -tvf $DEST/$NOW.tar.gz\n ```\nexample:\n\u003e```\n\u003e # tar -tvf /volum/@backup/mysql/daglig/[backupfile].tar.gz\n\u003edrwxr-xr-x root/root         0 2018-11-11 11:32 2018-11-11_1132/\n\u003edrwx------ root/root         0 2018-11-11 11:32 2018-11-11_1132/mysql/\n\u003e-rw-r--r-- root/root       831 2018-11-11 11:32 2018-11-11_1132/mysql/mysql.sql\n\u003e ```\n## restore database:\n ```\ntar -xf [backupfile].tar.gz\ncd .[backupfile]/mysql/\nmysqladmin -u root -p[root_password] create[database_name]\nmysql -u root -p[root_password] [database_name] \u003c dumpfilename.sql\n ```\n## Setup crontab:\n```\necho \"#mysql database backup\n32 1 * * * root /etc/scripts/db_backup_daglig.sh \u003e /dev/null 2\u0026\u003e1\n44 * * * * root /etc/scripts/db_backup_horly.sh  \u003e /dev/null 2\u0026\u003e1\" | tee /etc/cron.d/backup_MYsql\n```\n### Verfie that cron is working\n```\ngrep \"/etc/tilpasset/db_backup_horly.sh\" /var/log/syslog\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorstein-eide%2Fbackupmysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftorstein-eide%2Fbackupmysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorstein-eide%2Fbackupmysql/lists"}