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.

Learn DrupalDrupal glossary

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/status before 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

Questions about Site maintenance

Site maintenance is the ongoing work of updating, backing up and checking a site. Maintenance mode is one Drupal setting that takes the site offline for visitors while some of that work happens. Backups and status checks do not need it.

They see only the maintenance message, with the HTTP status 503. Requests in a non-HTML format get the same message as plain text, also with a 503. Users with the Use the site in maintenance mode permission can still use the site, and everyone can reach the login page.

Run drush maint:set 1 and, when the work is done, drush maint:set 0. The command drush maint:status exits with code 3 while the mode is on, which lets a script stop before it runs cron.

No. The Drush updatedb command enables maintenance mode by itself during the update, and so does update.php. The User Guide's core update steps still turn it on first and off afterward.

Related terms

All Drupal terms from A to Z