Last active
July 7, 2020 06:46
-
-
Save timkuijsten/6067107 to your computer and use it in GitHub Desktop.
mysql per database backup without mysql.event warning
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 - | |
# The important part is not to put the password as an argument to the mysql | |
# commands, i.e. don't use the -p option. Instead use a .my.cnf file in the home | |
# dir of the user you are running this script as, i.e. /root/.my.cnf if running | |
# as root. Make the file readable for the owner only: chmod 400 /root/.my.cnf | |
# See: http://stackoverflow.com/questions/17829659/securing-backup-credentials-for-mysqldump/17844997#17844997 | |
umask 007 | |
renice 10 $$ >/dev/null | |
BACKUPPATH=/home/backup/last | |
for db in `mysql --batch --skip-column-names --execute="SHOW DATABASES" | egrep -v 'performance_schema|information_schema'`; do | |
/usr/bin/nice /usr/bin/mysqldump --events --ignore-table=mysql.event --single-transaction --quick --extended-insert "$db" | gzip > "${BACKUPPATH}/mysql_${db}.sql.gz" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, makes more sense now. Thank you