Skip to content

Instantly share code, notes, and snippets.

@anytizer
Created July 10, 2016 16:59
Show Gist options
  • Save anytizer/43198c5a11d5d1d71e6f0002832a0227 to your computer and use it in GitHub Desktop.
Save anytizer/43198c5a11d5d1d71e6f0002832a0227 to your computer and use it in GitHub Desktop.
Backup all databases at once with one shell script.
#!/bin/bash
# Backup all available databases
USERNAME="root";
PASSWORD="password";
for DATABASE in `mysql -u${USERNAME} -p${PASSWORD} -e "SHOW DATABASES;"`
do
echo mysqldump --routines -u${USERNAME} -p${PASSWORD} ${DATABASE} \> ${DATABASE}.dmp;
mysqldump --routines -u${USERNAME} -p${PASSWORD} ${DATABASE} > ${DATABASE}.dmp;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment