Skip to content

Instantly share code, notes, and snippets.

@cal
Last active December 21, 2015 10:39
Show Gist options
  • Save cal/6293395 to your computer and use it in GitHub Desktop.
Save cal/6293395 to your computer and use it in GitHub Desktop.
#!/bin/bash
credentials=''
database=''
TABLES=`mysql $credentials -B -N -e "select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA='$database'"`
for table in $TABLES; do
echo -n "dumping $database.$table... "
if [[ $table == cache* ]]; then
option="--no-data"
else
option=""
fi
mysqldump $credentials $option $database $table | gzip > $database.$table.sql.gz
echo "done"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment