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
Run PHP in Drupal
Evaluate PHP with Drupal bootstrapped.
vendor/bin/drush php:eval "echo \Drupal::VERSION;"