{"id":14972087,"url":"https://github.com/quickshiftin/mysqlbkup","last_synced_at":"2025-05-08T23:30:17.836Z","repository":{"id":6869085,"uuid":"8118074","full_name":"quickshiftin/mysqlbkup","owner":"quickshiftin","description":"Lightweight MySQL backup script in BASH","archived":false,"fork":false,"pushed_at":"2022-05-27T14:01:42.000Z","size":37,"stargazers_count":157,"open_issues_count":0,"forks_count":68,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-31T19:21:18.067Z","etag":null,"topics":["backup","cron","mysql-database"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quickshiftin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-10T02:23:32.000Z","updated_at":"2025-02-09T16:11:33.000Z","dependencies_parsed_at":"2022-09-18T11:03:07.460Z","dependency_job_id":null,"html_url":"https://github.com/quickshiftin/mysqlbkup","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quickshiftin%2Fmysqlbkup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quickshiftin%2Fmysqlbkup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quickshiftin%2Fmysqlbkup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quickshiftin%2Fmysqlbkup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quickshiftin","download_url":"https://codeload.github.com/quickshiftin/mysqlbkup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253163242,"owners_count":21864046,"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","cron","mysql-database"],"created_at":"2024-09-24T13:46:22.212Z","updated_at":"2025-05-08T23:30:17.780Z","avatar_url":"https://github.com/quickshiftin.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"mysqlbkup\n=========\n\nLightweight MySQL backup script to backup all your MySQL databases every night.\n\nIn a matter of minutes you can setup nightly backups of your MySQL databases on\nany Linux server with mysqldump and standard GNU utilities.\n\nInstructions\n------------\n1. Download the package\n2. Run the installer via sudo - `sudo ./install`\n3. Configure database and backup parameters (see **[Configuration](https://github.com/quickshiftin/mysqlbkup/edit/master/README.md#configuration)** below)\n4. Setup a CRON job (see **[CRON](https://github.com/quickshiftin/mysqlbkup/edit/master/README.md#cron)** below)\n\nConfiguration\n-------------\n**Database Settings**\n\nThese are configured in /etc/mysqlbkup.cnf. Editing this file is similar to /etc/my.cnf.\n\nThere are sensible defaults for mysqldump parameters, but you may adjust them to your needs.\n\n**Backup Settings**\n\nThese are configured in /etc/mysqlbkup.config\n\n`$BACKUP_DIR`  - The directory where backups are written\n\n`$MAX_BACKUPS` - Number of backups per database (default 3)\n\n**Compression Settings**\n\nThese are configured in /etc/mysqlbkup.config\n\n`$BKUP_BIN` - The binary used to compress mysqldump files\n\n`$BKUP_EXT` - The extension used for compressed backup files\n\nThe default compression program is `gzip` and the default extension is _.gz_.\nYou may change these to any program and extension you wish, in which case take note the various examples below will have different extensions accordingly.\n\n**Database filter Setting**\n\nThese are configured in /etc/mysqlbkup.config\n\n`$DB_EXCLUDE_FILTER` - Filter to exclude databases from the backup (see [Excluding databases from backup](https://github.com/quickshiftin/mysqlbkup/edit/master/README.md#user-content-excluding-databases-from-backup) below)\n\nCRON\n----\nThe cron is simple, just schedule it once per day.\n\nHere we redirect *STDOUT* to a log file and *STDERR* to a separate log file.\n\n    ## mysql backups --------------------------------------\n    1 2 * * * /usr/local/bin/mysqlbkup.sh 1\u003e\u003e /var/log/mysqlbkup.log 2\u003e\u003e/var/log/mysqlbkup-err.log\n    \nWhat it does\n------------\nThe script will create directories beneath `$BACKUP_DIR`, named after the database.\nBeneath there, gzip files are created for each day the database is backed up.  There\nwill be at most `$MAX_BACKUPS` backup files for each database.\n\n    /var/db-backups/my_db/\n    2013-02-10-my_db.sql.gz  2013-02-11-my_db.sql.gz  2013-02-12-my_db.sql.gz\n\nRetrieving a backup\n-------------------\nJust drill down into the directory of the database you desire to restore\n(or copy to another location). Take the prior example for instance. Suppose you wish to\nunpack it in your home directory and view the contents of the database. You simply copy\nand `gunzip` the file.\n\n    # Copy the database backup to your home directory\n    cp /var/db-backups/my_db/2013-02-12-my_db.sql.gz ~\n    # Unpack the database\n    gunzip ~/2013-02-12-my_db.sql.gz\n\nAt this point `~/2013-02-12-my_db.sql` is available as a normal plain text SQL file.\n\nRestoring a backup\n------------------\nRestore an unzipped SQL file:\n\n    mysql -h [host] -u [uname] -p[pass] [dbname] \u003c [backupfile.sql]\n\nRestore a zipped SQL file:\n\n    gunzip \u003c [backupfile.sql.gz] | mysql -h [host] -u [uname] -p[pass] [dbname]\n    \nExcluding databases from backup\n-------------------------------\nThe filter string is space-separated list of entries that indicate databases to exclude. You may do an exact match such as\n```\nDB_EXCLUDE_FILTER='my_db'\n```\nBy default excluding filter entries use [BASH pattern matching](http://www.gnu.org/software/bash/manual/bash.html#Pattern-Matching). So you might test for a prefix in the database name with a filter like this\n```\nDB_EXCLUDE_FILTER='wp_*'\n```\nIf BASH pattern matching isn't good enough for some reason, you may alternatively use [POSIX regular expressions](http://www.regular-expressions.info/posix.html) by prefixing your entry with a tilde. For example\n```\nDB_EXCLUDE_FILTER='~.*_test'\n```\nAgain, these are space-separated entries and you can mix and match, so to include all 3 of the examples in one filter\n```\nDB_EXCLUDE_FILTER='my_db wp_* ~.*_test'\n```\n\nRequirements\n------------\n`mysql` \u0026 `mysqldump` as well as GNU versions of the following programs\n`date`, `gzip`, `head`, `hostname`, `ls`, `rm`, `tr`, `wc`\n\nIf you override `gzip` using the `$BKUP_BIN` option, the binary you choose must be installed and will be checked during script execution.\n\nDry Run\n-------\nTo test the script's configuration you may invoke it passing _'dry'_ as the first argument.\n```\nmysqlbkup.sh dry\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquickshiftin%2Fmysqlbkup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquickshiftin%2Fmysqlbkup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquickshiftin%2Fmysqlbkup/lists"}