Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- DB_HOST=""
- DB_DATABASE=""
- DB_USERNAME=""
- DB_PASSWORD=""
- read -r -d '' tableSizesQuery << EOF
- SELECT
- table_schema as `Database`,
- table_name AS `Table`,
- round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
- FROM information_schema.TABLES
- WHERE table_schema = '${DB_DATABASE}'
- ORDER BY (data_length + index_length) DESC;
- EOF
- # echo $tableSizesQuery;
- # exit;
- EXCLUDED_TABLES=(
- table1
- table2
- )
- IGNORED='';
- for TABLE in "${EXCLUDED_TABLES[@]}"; do:
- IGNORED+=" --ignore-table=${DB_DATABASE}.${TABLE}"
- done
- 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