Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#! /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
@timkuijsten

This comment has been minimized.

Copy link

timkuijsten commented Feb 9, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.