Last active
January 5, 2019 18:59
-
-
Save lukas-mertens/c7649ba44b14454fa08053b4a427697c to your computer and use it in GitHub Desktop.
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 | |
BACKUP_DIR="/opt/backup/mysql-backup" | |
MYSQL_USR="root" | |
MYSQL_PWD="your-password" | |
MYSQL_CMD=/usr/bin/mysql | |
MYSQL_DMP=/usr/bin/mysqldump | |
databases=`$MYSQL_CMD --user=$MYSQL_USR -p$MYSQL_PWD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"` | |
for db in $databases; do | |
echo "Dumping $db ..." | |
$MYSQL_DMP --force --opt --user=$MYSQL_USR -p$MYSQL_PWD --databases $db | gzip > "$BACKUP_DIR/$db.gz" | |
done | |
echo "-- DONE!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment