Skip to content

Instantly share code, notes, and snippets.

@grekko
Created February 24, 2012 11:11
Show Gist options
  • Save grekko/1900200 to your computer and use it in GitHub Desktop.
Save grekko/1900200 to your computer and use it in GitHub Desktop.
MySQLdump all database in separate files
#!/bin/bash
DBUSER=root
DBPASS=deinrootpasswort
DUMPDIR=./DatabaseDumps
DUMPDATE=$(date '+%Y-%m-%d')
if [ ! -d $DUMPDIR ] ; then
mkdir $DUMPDIR
fi
for IDX in $(echo "show databases;" |mysql --user=$DBUSER --password=$DBPASS -s)
do
mysqldump --user=$DBUSER --password=$DBPASS --databases $IDX > $DUMPDIR/${IDX}_${DUMPDATE}.sql
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment