Skip to content

Instantly share code, notes, and snippets.

@vml-rmott
Forked from timmillwood/drupal-quick-dump.sh
Last active August 29, 2015 14:16
Show Gist options
  • Save vml-rmott/165256b87b1ede6e8629 to your computer and use it in GitHub Desktop.
Save vml-rmott/165256b87b1ede6e8629 to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage: drupal-quick-dump database (assumes use of .my.cnf)
DB="$1"
DATE=`date +%Y%m%d`
# Dump Structure
echo "Starting to dump the table structure."
TABLES=`mysql --skip-column-names -e 'show tables' ${DB}`
mysqldump --complete-insert --disable-keys --single-transaction --no-data ${DB} ${TABLES} > ${DB}.${DATE}.sql
# Dump Data, Excluding Certain Tables
echo "Starting to dump the table data."
TABLES2=`echo "$TABLES" | grep -Ev "^(accesslog|cache.*|flood|search_.*|semaphore|sessions|watchdog)$"`
mysqldump --complete-insert --disable-keys --single-transaction --no-create-info ${DB} ${TABLES2} >> ${DB}.${DATE}.sql
echo "Starting to gzip dump."
gzip -v ${DB}.${DATE}.sql
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment