Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. DB_HOST=""
  4. DB_DATABASE=""
  5. DB_USERNAME=""
  6. DB_PASSWORD=""
  7.  
  8. read -r -d '' tableSizesQuery << EOF
  9. SELECT
  10. table_schema as `Database`,
  11. table_name AS `Table`,
  12. round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
  13. FROM information_schema.TABLES
  14. WHERE table_schema = '${DB_DATABASE}'
  15. ORDER BY (data_length + index_length) DESC;
  16. EOF
  17.  
  18. # echo $tableSizesQuery;
  19. # exit;
  20.  
  21. EXCLUDED_TABLES=(
  22. table1
  23. table2
  24. )
  25.  
  26. IGNORED='';
  27. for TABLE in "${EXCLUDED_TABLES[@]}"; do:
  28. IGNORED+=" --ignore-table=${DB_DATABASE}.${TABLE}"
  29. done
  30.  
  31. mysqldump --host=${DB_HOST} --user=${DB_USERNAME} --password=${DB_PASSWORD} ${DB_DATABASE} ${IGNORED} -v > dump.sql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement