Drupal 11 cheatsheet

Drupal 11: Database and debugging

7 common Drupal 11 tasks.

Back up the database

Write the database to a SQL file.

vendor/bin/drush sql:dump --result-file=../backup.sql

Restore the database

Import a SQL file into the site's database.

vendor/bin/drush sql:cli < ../backup.sql

Caution: Overwrites existing tables. Take a fresh backup first.

Run a SQL query

Run a query against the site's database.

vendor/bin/drush sql:query "SELECT name, status FROM users_field_data"

Show recent log messages

Print the latest entries from the database log.

vendor/bin/drush watchdog:show --count=20

Follow the log

Stream new log messages as they arrive.

vendor/bin/drush watchdog:tail

Run PHP in Drupal

Evaluate PHP with Drupal bootstrapped.

vendor/bin/drush php:eval "echo \Drupal::VERSION;"

Generate a module skeleton

Interactively scaffold a custom module.

vendor/bin/drush generate module

Was this page helpful?