Skip to content

Instantly share code, notes, and snippets.

@joeydi
Created October 5, 2021 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeydi/ec5bba96de3ad7a8625f51e0d387dad6 to your computer and use it in GitHub Desktop.
Save joeydi/ec5bba96de3ad7a8625f51e0d387dad6 to your computer and use it in GitHub Desktop.
Export All MySQL Databases
#!/bin/bash
USER="root"
PASSWORD="root"
ExcludeDatabases="Database|information_schema|performance_schema|mysql|sys"
databases=`mysql -u$USER -p$PASWORD -e "SHOW DATABASES;" | tr -d "| " | egrep -v $ExcludeDatabases`
for db in $databases; do
echo "Dumping database: $db"
mysqldump -u $USER -p$PASSWORD --databases $db > `date +%Y%m%d`.$db.sql
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment