Advertisement
Guest User

Untitled

a guest
May 11th, 2019
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #!/bin/bash
  2. # usage: drupal-quick-dump user host database
  3.  
  4. USER="$1"
  5. HOST="$2"
  6. DB="$3"
  7. DATE=`date +%Y%m%d`
  8.  
  9. # Get User Password
  10. echo "Please provide the password for ${USER} on db ${DB} hosted at ${HOST}:"
  11. read -se PASS
  12.  
  13. # Dump Structure
  14. echo "Starting to dump the table structure."
  15. TABLES=`mysql --skip-column-names -e 'show tables' -u ${USER} --password="${PASS}" -h ${HOST} ${DB}`
  16. mysqldump --complete-insert --disable-keys --single-transaction --no-data -u ${USER} --password="${PASS}" -h ${HOST} ${DB} ${TABLES} > ${DB}.${DATE}.sql
  17.  
  18. # Dump Data, Excluding Certain Tables
  19. echo "Starting to dump the table data."
  20. TABLES2=`echo "$TABLES" | grep -Ev "^(accesslog|cache.*|flood|search_.*|semaphore|sessions|watchdog)$"`
  21. mysqldump --complete-insert --disable-keys --single-transaction --no-create-info -u ${USER} --password="${PASS}" -h ${HOST} ${DB} ${TABLES2} >> ${DB}.${DATE}.sql
  22.  
  23. echo "Starting to gzip dump."
  24. gzip -v ${DB}.${DATE}.sql
  25.  
  26. echo "Done!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement