Skip to content

Instantly share code, notes, and snippets.

@zawyelwin
Created February 24, 2021 05:00
Show Gist options
  • Save zawyelwin/a0f44a6836d2dedfc30f0609f8bd4bd1 to your computer and use it in GitHub Desktop.
Save zawyelwin/a0f44a6836d2dedfc30f0609f8bd4bd1 to your computer and use it in GitHub Desktop.
Dump all databases without except system databases.
#!/bin/bash
host=<DB_HOST>
password=<DB_PASSWORD>
user=<DB_USER>
database=( $(mysql -h $host -u $user -p$password -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|mysql|performance_schema|tmp|sys)") )
for db in "${database[@]}"
do
mysqldump -h $host -u $user -p$password $db > $db.sql
echo "dumping $db....."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment