Skip to content

Instantly share code, notes, and snippets.

@arduanov
Created January 19, 2015 12:33
Show Gist options
  • Save arduanov/d1359a77c2592643d23b to your computer and use it in GitHub Desktop.
Save arduanov/d1359a77c2592643d23b to your computer and use it in GitHub Desktop.
#!/bin/bash
USER="root"
PASSWORD="5tgbnhy678"
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 $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