Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/donquixote/mysql-dump-all
https://github.com/donquixote/mysql-dump-all
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/donquixote/mysql-dump-all
- Owner: donquixote
- Created: 2013-03-18T05:10:38.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-03-18T05:26:07.000Z (over 11 years ago)
- Last Synced: 2023-03-10T21:13:01.497Z (over 1 year ago)
- Language: PHP
- Size: 105 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This script will
- Dump all your mysql databases.
- One file per database, gzipped, in `./dump/now/$dbname.sql.gz`.
- Drupal `cache_*` and similar tables are skipped.
- Maintain hourly, daily, monthly, yearly archives of the `./dump/now folder`.
E.g. `./dump/weekday/tue/..` contains the latest dump that was made on a tuesday.
- Use symlinks to reduce data duplication in the archives.
E.g. if today is tuesday, then `./dump/weekday/tue` will be a symlink to `./dump/now`.
- Rotate those archives.
E.g. if today is wednesday, but `./dump/weekday/tue` is found to be a symlink to `./dump/now`, then
- The symlink at `./dump/weekday/tue` will be deleted.
- Instead, the folder `./dump/now` will be copied to `./dump/weekday/tue`.
- This is supposed to happen *before* the dumps in `./dump/now` are updated.How to use:
- PHP is required.
(I find PHP more readable than plain shell script)
- Create a backup db user with pw and readonly privileges on all databases:
`GRANT LOCK TABLES, SELECT, SHOW VIEW ON *.* TO 'backup'@'localhost' IDENTIFIED BY '*****';`
- Copy `example.settings.ini` to `settings.ini` and configure it with the db user credentials.
- `php rotate.sh.php | sh` will rotate the archives.
- `php dump-all.sh.php | sh` will dump all tables.
- `sh dump-all.sh` is the combination of rotate and dump-all.
This is what you want to put in your cron.Archive spreading:
- hourly dump for the last 4 hours
- 3-hourly dump for the last 24 hours
- daily dump for the last 7 days
- monthly dump for the last 4 months
- 3-monthly dumps for the last year
- yearly dumps forever(might not be correct to the last detail, but you get the idea)