Skip to content

Instantly share code, notes, and snippets.

@rashivkp
Forked from cal/dump.sh
Last active August 29, 2015 14:09
Show Gist options
  • Save rashivkp/3ec4fe821f9d4215c81d to your computer and use it in GitHub Desktop.
Save rashivkp/3ec4fe821f9d4215c81d 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