Updating Drupal core via Drush
This documentation is deprecated.
Updating using Drush 9 and 10 is deprecated.
Use Composer to manage Drupal dependencies. Drush 9 and newer no longer supports updating Drupal.
Always revert to a backup when you get a fatal error in the update process.
Steps to update Drupal core using Drush 8.x. Drush is the Drupal Shell--the command line interface for Drupal.
-
Back up both your files and database. Using Drush, type in and execute this command.
drush archive-dump
Notes:
-
It is important to create backups before updating, so that if something unexpected shows up during or after the update, you will be able to quickly and easily revert the update.
-
This "drush archive-dump" command above creates a .tar.gz of files and the database. This is a legacy Drush command which is slated to be removed from Drush. This command only archives files located under /web directory.
-
- Check for available updates
drush pm-updatestatus
- Note: The alias for the command
ups
- Note: This command is deprecated for composer based installation, please use
composer-show
- Note: The alias for the command
- Activate maintenance mode
drush state-set system.maintenance_mode 1
Note: The alias for the command is
sset
- Clear the cache
drush cache-rebuild
Notes:
- The alias for the command is
cr
- This command clears the cache_* bins in the Drupal database, and then rebuild the site's container
- The alias for the command is
- Choose one or more options below to execute the updates. Which option(s) you choose depends on what type of update(s) are needed.
pm-update
(alias:up
) both updates the code as well as apply any pending database updates, the same aspm-updatecode
+updatedb
.- Option: Update Drupal core
drush pm-update drupal
- Option: Update Drupal core to a development branch, for testing and patch creation only (not Production)
drush pm-update drupal-8.5.x-dev
- Option: Update a single module
drush pm-update module_name
- Option: Update only security updates
drush pm-update --security-only
- Option: Update Drupal core
- If appropriate, re-apply any manual modifications to files such as .htaccess, composer.json, or robots.txt. Drush does not do this automatically.
- Reapply any core patches you were using before the upgrade (assuming that these haven't been merged yet).
- These are easy to find with good commit messages.
% git log --oneline --reverse core
ee2bf8dd Issue #18: Updated Drupal core from 8.3.4 to 8.3.5.
267e3ad0 Issue #27: Applied patch from https://www.drupal.org/project/drupal/issues/2174633#comment-12291691.
718ecba5 Issue #9: Applied patch from https://www.drupal.org/project/drupal/issues/2906229#comment-12496488.
- For each previously applied patch since the last core update, use the git cherry-pick command (or fix conflicts if it fails) in chronological order.
% git cherry-pick 267e3ad0
% git cherry-pick 718ecba5
...
- These are easy to find with good commit messages.
- If using Composer to manage PHP libraries (e.g. because some contributed modules require it), update your /vendor directory with the following command:
composer update drupal/core --with-dependencies
- Update database, if any required database updates are needed
drush updatedb
Note: The alias for the command is
updb
. - Check that your site is ok. To do so:
- Using Drupal, look at the status report page
- Using a browser test your site by visiting important pages
- Deactivate maintenance mode
drush state-set system.maintenance_mode 0
- Clear the cache again
drush cache-rebuild
- Done. You have successfully updated your Drupal using Drush :)
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion