Skip to content

Instantly share code, notes, and snippets.

@skillmatic-co
Created December 14, 2015 19:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save skillmatic-co/7dcef92a33bf8cec0023 to your computer and use it in GitHub Desktop.
Save skillmatic-co/7dcef92a33bf8cec0023 to your computer and use it in GitHub Desktop.
#!/bin/bash
USER="root"
PASSWORD=""
databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
for db in $databases; do
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
echo "Dumping database: $db"
mysqldump -u $USER -p$PASSWORD --databases $db > `date +%Y%m%d`.$db.sql
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment