Skip to content

Instantly share code, notes, and snippets.

@richardbporter
Created May 9, 2022 12:37
Show Gist options
  • Save richardbporter/129c2c7882df36a93b928d9d25a2b5b9 to your computer and use it in GitHub Desktop.
Save richardbporter/129c2c7882df36a93b928d9d25a2b5b9 to your computer and use it in GitHub Desktop.
Drupal database size
## Check the size of database used by Drupal (MySQL is expected).
drupal_db_name="$(drush sql-conf | grep "database" | grep -Eo "\S+$")"
if [[ -z "$drupal_db_name" ]]; then
echo "usage: run this command under a drupal instance directory."
return
fi
$(drush sql-connect) -e "SELECT table_schema AS \"Database\", SUM(ROUND(((data_length + index_length) / 1024 / 1024), 2)) AS \"Size in MB\" FROM information_schema.TABLES WHERE table_schema = \"$drupal_db_name\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment