# Browse to https://github.com/drush-ops/drush/releases and download the drush.phar attached to the latest 8.x release.
# Test your install.
php drush.phar core-status
# Rename to `drush` instead of `php drush.phar`. Destination can be anywhere on $PATH.
chmod +x drush.phar
sudo mv drush.phar /usr/local/bin/drush
# Optional. Enrich the bash startup file with completion and aliases.
# Before you begin
It's recommended to use Composer to manage Drupal dependencies; read Using Composer with Drupal for more information. Drush 9 no longer supports updating Drupal and leaves the work to composer. Hence it is recommended to use Composer to update Drupal. However, if you are a long-time Drush user, you may still use Drush 8 (8.14 or newer) to update Drupal 8.
PS! The introduction to these instructions summarizes all your update options to choose from.
Always revert to a backup when you get a fatal error in update process.
# Update Drupal 8 core
Steps to update Drupal 8 core using Drush 8.x. Drush is the Drupal Shell.
Backup both your files and database. Using Drush, type in and execute this command.
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 for removal in Drush. This command only covers files located under /web directory.
Check for available updates
Note: This command above is a short for drush pm-updatestatus
Activate maintenance mode
drush sset system.maintenance_mode 1
Clear the cache
"cr" is a short for "cache rebuild"
This command clear the cache_* bins in the Drupal database, and then rebuild the site's container
Choose one or more options below to execute the updates. Which option(s) you choose depends on what type of update(s) are needed.
Option: Update Drupal 8 core
drush up drupal
Option: Update Drupal 8 core to a development branch, for testing and patch creation only (not Production)
drush up drupal-8.5.x-dev
Option: Update a single module
drush up module_name
Option: Update only security updates
drush up --security-only
If appropriate, re-apply any manual modifications to files. Such as .htaccess, composer.json, or robots.txt. As 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
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
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 sset system.maintenance_mode 0
Clear the cache again
Done. You have successfully updated your Drupal 8 using Drush :)