Created
June 29, 2020 08:07
-
-
Save rikmeijer/be3d526ebee46f5c51f1a021ff866da9 to your computer and use it in GitHub Desktop.
Daily mysql cron dumping all tables, except for information_schema. Writing backups to /var/backups/mysql.
This file contains 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/sh | |
/usr/bin/find /var/backups/mysql/* -mtime +7 -exec rm {} \; | |
for DB in $(mysql -e 'show databases' -s --skip-column-names); do | |
if [ "$DB" = "information_schema" ] | |
then | |
echo Skipping $DB | |
continue | |
fi | |
echo -n Dumping $DB... | |
/usr/bin/mysqldump --add-drop-database --add-drop-table --single-transaction --routines --triggers $DB | gzip > "/var/backups/mysql/$DB-$(date '+%Y%m%e').sql.gz"; | |
echo done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment