-
-
Save ryanburnette/9456453 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 | |
TIMESTAMP=$(date +"%F") | |
BACKUP_DIR="./$TIMESTAMP" | |
MYSQL_USER="backup" | |
MYSQL_PASSWORD="" | |
mkdir $BACKUP_DIR | |
databases=`mysql --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"` | |
for db in $databases; do | |
mysqldump --force --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db --ignore-table=mysql.event | gzip > "$BACKUP_DIR/$db.gz" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using the password as an argument to the mysql* commands is insecure. Anyone who executes
ps auxww
while this script is running can see the password. I've updated my script to make this more clear.