Skip to content

Instantly share code, notes, and snippets.

@stefanpejcic
Created April 16, 2024 18:04
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 stefanpejcic/1e1ebafe2e80c81aaafc39129b27347b to your computer and use it in GitHub Desktop.
Save stefanpejcic/1e1ebafe2e80c81aaafc39129b27347b to your computer and use it in GitHub Desktop.
dump_all_mysql_databases.sh
#!/bin/bash
databases=`mysql -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 "Exporting database: $db"
mysqldump --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