Skip to content

Instantly share code, notes, and snippets.

@faisal-ibrahim
Forked from anytizer/backup-all-databases.sh
Created December 18, 2016 17:25
Show Gist options
  • Select an option

  • Save faisal-ibrahim/b662da6a4d1c886d5ff45be07590ca00 to your computer and use it in GitHub Desktop.

Select an option

Save faisal-ibrahim/b662da6a4d1c886d5ff45be07590ca00 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