Created
May 9, 2022 12:37
-
-
Save richardbporter/129c2c7882df36a93b928d9d25a2b5b9 to your computer and use it in GitHub Desktop.
Drupal database size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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