We recently got a new Drupal 8 project that was implemented by other developers a while ago and hadn’t been maintained for months.
One of the challenges we faced was that Drupal 8 core and modules were never upgraded, and when we tried to upgrade from Drupal 8.1.0 to 8.4.3 we got a lot of errors. That led us to define a strategy to upgrade and test Drupal and modules one version at a time, by using drush and git commands.
This is the process we followed for every Drupal version upgrade:
- Use this website to look for Drupal 8 releases: https://www.drupal.org/project/drupal/releases
- Create a database backup of the stable version with
drush sql-dump --result-file=<sql-file>
- Run the following drush command to upgrade to the next release:
drush up drupal-<version>
.
For instance, to upgrade to version 8.2.0 the command should bedrush up drupal-8.2.0
- Clear cache with
drush cr
- Verify that website is not impacted by browsing front and back end.
- If upgrade was successful, add files to the git branch and commit, and proceed with point # 1 above.
This is the process we followed to revert changes, assuming that you didn’t commit changes and you are coming from point # 5 from the previous process:
- Remove files, which will be usually in core. I.e.:
rm -rf core
- Recover the latest version of those files with git:
git checkout -- core
- Run
git status
to check the status of the branch – hopefully at this point it will be clean, otherwise you’ll need to remove more files and recover the latest version of other files with the commands above. - Run
composer install
in case some files generated by that command were impacted.test - Import the database backup of the corresponding version:
drush sql-drop -y && drush sql-query --file=<sql-file> && drush updb -y