-
-
Save cinco/606f3fdd8289a004cd66a9b76dcf9e77 to your computer and use it in GitHub Desktop.
MariaDB / MySQL Backup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Simple script to dump the contents of a database into separate files in the directory "/backups/" | |
| # Symlink into /etc/cron.daily/ or add to crontab | |
| # Originally from: https://gist.github.com/brianredbeard | |
| # /usr/local/scripts/db_dump | |
| #mysqldump -x --add-drop-table --all-databases > /backups/mysqldb-`date +%F-%I%p`.sql | |
| /usr/bin/mysql --defaults-extra-file=/root/.my.cnf -e 'show databases' | /bin/awk '{print $1}' | /bin/grep -v "^Database$" | /usr/bin/xargs -i{} /usr/bin/mysqldump --defaults-extra-file=/root/.my.cnf --opt -Q -r /backups/{}-`date +%F-%I%p`.sql {} | |
| gzip -q /backups/*.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment