Skip to content

Instantly share code, notes, and snippets.

@TheAndrey
Last active September 30, 2022 08:41
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 TheAndrey/2b9b3484f116bfbf0dba8eb782ccbdf8 to your computer and use it in GitHub Desktop.
Save TheAndrey/2b9b3484f116bfbf0dba8eb782ccbdf8 to your computer and use it in GitHub Desktop.
MySQL Backup
#!/bin/bash
for dbname in `echo SHOW DATABASES | mysql | grep -v Database`;
do
case $dbname in
information_schema)
continue ;;
mysql)
continue ;;
performance_schema)
continue ;;
test)
continue ;;
sys)
continue ;;
*)
echo "Dumping: $dbname"
mysqldump --routines --hex-blob --skip-comments --complete-insert --lock-all-tables $dbname --result-file=$dbname.sql && gzip $dbname.sql ;;
esac
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment