Skip to content

Instantly share code, notes, and snippets.

@oterox
Last active August 29, 2015 14:16
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 oterox/9b6cc85aa1a3c497074f to your computer and use it in GitHub Desktop.
Save oterox/9b6cc85aa1a3c497074f to your computer and use it in GitHub Desktop.
Mysql backup all databases to single files
#!/bin/bash
WP_DBUSER=root
WP_DBPASS=password
BCK_FILE_DB=/path/to/backups/
DBS=`mysql -u$WP_DBUSER -h localhost -p$WP_DBPASS -Bse 'show databases'`
for db in $DBS
do
echo 'database:' $db
mysqldump --add-drop-table -h localhost -u $WP_DBUSER -p $db --password=$WP_DBPASS | gzip > $BCK_FILE_DB$db.tar.gz
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment