Site maintenance
Keeping a Drupal site secure and working: update it, back it up, read the status report. Maintenance mode is the optional switch that takes it offline.
In Drupal, site maintenance is the set of recurring tasks that the User Guide covers in its chapters Preventing and Fixing Problems and Security and Maintenance: backups, log and status report checks, cron, and security and regular updates to core, modules and themes. Maintenance mode is a separate core setting that serves some of these tasks.
What maintenance involves in Drupal 11
The User Guide separates two kinds of updates. Security updates fix security bugs and must be applied to keep a site secure. Other updates add features and fix bugs and are released periodically. It advises trying updates on a development copy before the live site.
- Updates. With Composer,
composer outdated "drupal/*"lists what is behind; the example below shows a core update. Drupal.org says to check the Status report at/admin/reports/statusbefore and after, and to fix its errors and warnings. - Backups. Drupal.org says to always back up your files and database before updating. The User Guide also suggests testing a restore, for example by making a development copy.
- Cron. The User Guide describes cron as routine operations such as checking for module and theme updates, indexing content for search and cleaning up temporary files.
Maintenance mode
Go to Configuration › Development › Maintenance mode (/admin/config/development/maintenance). Tick Put site into maintenance mode, write a message and save. The route accepts either the Administer site configuration or the Administer software updates permission.
While the mode is on, visitors get the message with a 503 status. Login pages and password reset remain reachable, so people with the Use the site in maintenance mode permission can sign in. The message accepts the @site placeholder for the site name. The on/off switch is a State value, system.maintenance_mode, while the message is the configuration item system.maintenance:message.
Example
An abridged minor core update from the command line, after the Drupal.org steps:
drush sql:dump
composer update "drupal/core-*" --with-all-dependencies
drush updatedb
drush cache:rebuild
Afterwards, open the Status report and test the site while logged out. Drupal.org adds that updatedb activates maintenance mode itself.
Common mistakes
- Testing while logged in. The User Guide says to check from a browser where you are not logged in, because users with the right permission still see the site.
- Forgetting to switch it off. Users who may use the site in maintenance mode see the message "Operating in maintenance mode", and those with Administer site configuration also get a Go online link.
- Overwriting the only backup. The User Guide advises keeping a series of backups, because a problem may be noticed late.
For marketing and content teams
Ask your developers when updates will happen, because visitors see only the maintenance message while the mode is on. The message is editable on the maintenance mode page, so agree on its wording in advance. Schedule launches and newsletters around such windows.
With DXPR
The DXPR Builder update guide asks you to back up the database with drush sql:dump, try the update on a staging copy first, run composer update drupal/dxpr_builder --with-dependencies, then drush updatedb and drush cache:rebuild. See updating DXPR Builder.
Sources
- Drupal User Guide: Enabling and disabling maintenance mode
- Drupal User Guide: Concept: Security and regular updates
- Drupal User Guide: Concept: Cron
- Drupal User Guide: Concept: Data backups
- Drupal.org: Updating Drupal core via Composer
- Drupal core 11.4.10: SiteMaintenanceModeForm
- Drupal core 11.4.10: MaintenanceModeSubscriber
- Drupal core 11.4.10: DbUpdateController
- Drupal core 11.4.10: system.permissions.yml
- Drush maint:set command
- Drush maint:status command
- Drush updatedb command
- DXPR: Updating DXPR Builder