Updating Drupal: A Guide to Routine Updates and Major Upgrades

If your Drupal site isn’t regularly updated, you’re missing out. New Drupal releases often introduce feature updates that can enhance your site’s usability and performance. They also address security issues to help keep your site safe from attack and include fixes for bugs.

But keeping Drupal up-to-date isn’t always simple. You have to track when a new release is available and then decide whether the benefits it offers merit updating your site. Drupal doesn’t provide a native option to update itself automatically, so you’ll need to handle the process manually or use a third-party module to enable automatic updates.

New call-to-action

This guide helps you make the updating process as painless as possible, with an overview of how to prepare for and carry out an update — or a major upgrade —  to Drupal. Here’s a handy table of contents so you can navigate to the information you need now:

Drupal Updates and Upgrades
Updating Drupal - Getting Ready
     Follow the Release Feed
     Back Up
     Consider Automatic Updates
How to Update Drupal
     Updating Manually
          Updating with the Shell
     Updating Using Composer
     What about Drush?
     Handling Update Issues
Upgrading Drupal
     Preparing to Upgrade
     Moving from Drupal 6 or 7 to Drupal 8 or 9
     Moving from Drupal 8 to 9
Keep Drupal Up-to-Date Without Missing a Beat


Drupal Updates and Upgrades

The word “update” usually refers to any type of change from one version of a software platform to another. However, the Drupal community draws a distinction between updates and upgrades.

An update in Drupal is a change from one version to another within the same release. For example, if you change your installation from Drupal 7.79 to 7.80, you’re performing an update. Updates are typically easier to perform and carry fewer risks of something going wrong.

You perform an upgrade when you change from one major Drupal release to another, like moving from Drupal 8 to Drupal 9. Upgrades generally require more planning and effort than updates. That said, the difficulty of performing an upgrade also depends in part on the releases involved. Moving from Drupal 6 or 7 to Drupal 8 or 9 requires migrating your entire Drupal site. But if you are already on Drupal 8 and want to upgrade to Drupal 9, a site migration is not necessary, which makes the upgrade process simpler.

Why Upgrade to Drupal 9

Drupal 9 is representative of the current, significant shifts that are occurring in the crowded CMS landscape. Today, it’s more important for organizations to offer aesthetically pleasing and unique digital experiences that are targeted towards specific visitor demographics. Here, Drupal 9 can help: Using its modernized modules, tools and expanded open source network, a company can integrate platforms into their website that will automatically collect visitor demographics and then use that information to convert potential leads into returning customers. 

For example, companies can add real-time sales alerts or advanced email reporting for specific audiences. They can even track site traffic to see how many conversions or sign-ups have been achieved in real-time or for a particular day, week, month or year. With these features, organizations better attract and engage their visitors by proactively delivering personalized and helpful content or services to them. 

Drupal 9 also makes it easier than ever before to create a website, add functionalities to it and make corrections when necessary. For instance, the Upgrade Reactor module offers automated code fix suggestions to make your modules compatible with Drupal 9. This feature makes it easier for teams to develop or adjust new code. In Drupal 9, the coding around modules and APIs has been modernized and contains built-in performance features that help websites load quickly, even during extreme traffic bursts.  

Updating Drupal — Getting Ready

No matter whether you’re updating or upgrading, there are a few best practices to keep in mind as you prepare.

Follow the Release Feed

To determine when an update or upgrade is warranted, track Drupal’s release notes, which explain what’s new in each version. You should also follow Drupal security advisories so you’ll know if a version you’re using is vulnerable to a security issue.

Back Up

Even during a well-planned minor update, you may run into an unexpected issue that renders your Drupal installation unusable and unrecoverable. You should always create backups beforehand by copying your site content, Drupal configuration data, and database to a separate system.

Consider Automatic Updates

As noted above, Drupal doesn’t provide support for automatic updates by default, but an optional module is available with this feature. The module requires some effort to set up, and it currently lacks important features, like support for rolling back to an earlier version in case something goes wrong during an update. Still, if you anticipate updating Drupal often, it may be worth taking advantage of the automatic updates module.

Timeframe to Expect

For large enterprise sites, an upgrade can take a year or longer. Working with a partner like BlackMesh by Contegix can ensure the most efficient upgrade path is taken. Small to mid-sized organizations may be able to upgrade Drupal in 3-6 months. However, there is still quite a bit of work involved no matter what size the organization or how complex the application.

How to Update Drupal

There are two main ways to apply Drupal updates. One is to install them manually by moving the necessary files into place via an FTP client or by using shell commands. The other is to use Composer, a command-line tool that automatically makes the file and directory changes necessary to perform an update.

Although both approaches require familiarity with technical tools, Composer is generally the simpler option. Updating Drupal with Composer requires fewer steps. That said, you will need to familiarize yourself with Composer commands. That requirement makes manual updates a more attractive approach for people who don’t want to spend time learning a new tool. Composer also requires command-line access to the server hosting your Drupal installation. In some cases — for instance, if your Drupal hosting provider doesn’t offer shell-level access — you may not be able to open a shell, in which case updating via FTP is your only option.

Updating Manually

Whether updating Drupal manually using a shell or FTP, you should first back up your existing installation so that you can roll back to it in case something goes wrong during the update. You should also log into your Drupal web administration interface and put the site into maintenance mode. You can find this option at Administration > Configuration > Development > Maintenance mode.

After you’ve backed up the site and put it into maintenance mode, you’re ready to perform the update.

Updating with the Shell

To perform this process using a shell, first log into the Drupal server. Next, use the cd command to navigate to your Drupal installation directory:

          cd /path/to/drupal

Then use the rm command to delete the Drupal core and vendor directories:

          rm -r core vendor

Alternatively, you can use the mv command to move these directories to a different location:

          mv core core-backup
          mv vendor vendor-backup

Moving the directories allows you to keep the old installation on hand in case you need it later. That said, you generally shouldn’t keep every old version of Drupal you have, as this will eat up valuable storage space unnecessarily. You may want to keep only the second-most recent version on hand, for example, and delete versions older than that every time you perform a new update.

Next, remove all of the files — but not directories — in the top-level Drupal directory:

          rm *.* .[a-z]*

The shell may ask you to confirm each file deletion. If you don’t want to have to confirm each one, you can pass the -f flag to rm to force deletion without confirmation.

Now that you’ve removed the old directories, you can install the new, updated version in their place. The easiest way to do this in a shell is to download the new Drupal version using wget — or curl, if you’re on a system that doesn’t have wget installed — then extract it:

          wget https://ftp.drupal.org/files/projects/drupal-x.y.z.tar.gz
          tar zxf drupal-x.y.z.tar.gz

At this point, you’ll have updated versions of the core and vendor directories, but they won’t yet be copied into the right location on your Drupal server. To do that, run a few more commands:

          cd drupal-x.y.z
          cp -R core vendor /path/to/your/drupal/directory
          cp *.* .[a-z]* /path/to/your/drupal/directory

Some Drupal versions will require you to update the settings.php file as well when you install them. If this is a requirement, the release notes for the update will mention it. When necessary, you can update this file using the following steps. First, navigate to the /sites/default directory inside your Drupal installation:

          cd /path/to/drupal/sites/default

Then back up your existing settings.php file by renaming it:

          mv settings.php settings.php-backup

Copy the default.settings.php file that came with your new Drupal installation into this directory, naming it settings.php

          cp /path/to/new/drupal/release/default.settings.php settings.php

Finally, you’ll need to open the new settings.php file in a text editor, then manually apply any site-specific settings, like database information, to it. You can grab that data from the settings.php.backup file that you created previously.

With all of the above complete, the last step is to open your web browser and navigate to http://www.yoursite.com/update.php, with the name of your own Drupal site substituted for “yoursite.com”. This will update your database tables.

After that, your site should be updated. Verify that it works as expected, and if it does, you can take it back out of maintenance mode.

Updating Using Composer

To update Drupal using Composer, you should first back up the site and put it into maintenance mode by navigating to Administration > Configuration > Development > Maintenance mode in the Drupal admin web interface. Then open a shell in your Drupal server and check whether a supported update is available using this command:

          composer outdated "drupal/*"

Composer will respond with output that includes a line starting with drupal/core if an update is available.

To apply an update, assuming one is available, run the following command:

          composer update drupal/core "drupal/core-*" --with-all-dependencies

You may also want to update Drupal modules, which you can do with the following command:

          composer update drupal/modulename --with-dependencies

Then visit http://www.yoursite.com/update.php — with your site’s name substituted, as explained above — in your web browser to update database tables.

After you’ve completed these steps, check your site and take it out of maintenance mode if all looks as it should.

Note that if you’re updating from a Drupal version that preceded 8.8.0 to a later one, you may run into issues related to the template that Composer uses, as the Composer template changed with that version. The simplest way to work around this issue is to remove the vendor directory from your existing Drupal installation before updating. You can do so in the shell with this command:

          rm -r /path/to/drupal/vendor

What about Drush?

A third approach to updating Drupal is to use Drush, a command-line Drupal administration tool. Although some versions of Drush can still be used to update Drupal using the drush pm-update drupal command, the latest Drush releases no longer support Drupal updates. Updating via Composer, the shell, or FTP is therefore preferable to using Drush.

Handling Update Issues

You may run into a few common problems when performing a Drupal update:

  • Permissions or access errors. If your Drupal site or the update Web interface won’t load at all following an update, it could be a file permissions issue. Use the chmod command to modify file permissions.
  • Incompatible modules or themes. If Drupal reports that some of your modules or themes are incompatible with the new version, you’ll need to update those that are, assuming more recent versions are available that are compatible with the new Drupal installation. If they are not, you may need to install alternative modules or themes.
  • Incompatible PHP version. A new Drupal release may require the host server to have a more recent version of PHP than what your server has installed. In this case, the solution is to update PHP, if possible.
  • Can’t connect to the database. If Drupal reports being unable to connect to the database, verify that your database is configured correctly in your settings.php file.

If worst comes to worst, you can always roll back to the previous Drupal version. The easiest way to do this — provided you backed up your previous installation — is to put your old core and vendor directories back in place, along with the files you removed during the update. If you don’t have a backup, you can download an older Drupal version and install it, although you may need to reapply site-specific configuration changes in that case.

Upgrading Drupal

If you’re instead moving between major Drupal releases, you’ll need to upgrade your site.

Preparing to Upgrade

Before upgrading, you should first research the differences between your current Drupal release and the new one, then determine whether you will need to address any incompatibility problems. Some modules, themes, or other resources that you use in your current Drupal version may no longer be supported in the new one. The features between Drupal releases (such as versions 7 and 8) can also vary widely, and you should make sure that the new version offers the functionality you need.

You can automate parts of this evaluation process using a tool like drupal-check, which will parse the configuration data on your current installation and flag any code that appears incompatible with the upgrade you’re planning.

Moving from Drupal 6 or 7 to Drupal 8 or 9

There are two simple methods for upgrading between older versions of Drupal to Drupal 8 or 9: using the Drupal web interface or using Drush. To upgrade via the web, navigate to http://yoursite.com/upgrade. You’ll find a web interface that will walk you through the upgrade process.

To upgrade with Drush, you’ll use the drush migrate-upgrade command. Depending on your setup, you’ll likely need to pass additional arguments to the command. The Drupal documentation offers full details.

Moving from Drupal 8 to 9

If you’re upgrading from Drupal 8 to Drupal 9, using Composer is the preferred method. You’ll first need to ensure that your Drupal 8 site has been updated to the latest 8.x release. You next need to add write access to some of your site files using the chmod command:

          chmod 777 web/sites/default
          find web/sites/default -name "*settings.php" -exec chmod 777 {} \;
          find web/sites/default -name "*services.yml" -exec chmod 777 {} \;

Next, tell Composer to pull the dependencies for your new Drupal version:

          composer require drupal/core-recommended:^9.0.0 drupal/core-composer-scaffold:^9.0.0 drupal/core-project-message:^9.0.0 --update-with-dependencies --no-update

Replace the 9.0.0 string in the preceding commands with the string that corresponds to your new Drupal version.

With the dependencies prepared, you can now run the upgrade with this command:

          composer update

After the process completes, navigate to http://yoursite.com/update.php — changing the URL to your site’s name — to update your database tables.

Then remove the write access that you granted previously to some of your site files:

          chmod 755 web/sites/default
          find web/sites/default -name "*settings.php" -exec chmod 644 {} \;
          find web/sites/default -name "*services.yml" -exec chmod 644 {} \;

You can now verify that your upgraded installation works properly.

Keep Drupal Up-to-Date Without Missing a Beat

No matter how you choose to update your Drupal site, you’ll need knowledge of command-line tools or FTP. And you may run into issues like incompatible modules, broken configuration files, or an outdated PHP version on the host server.

BlackMesh by Contegix takes the burden of updating Drupal off your shoulders. In addition to offering a managed platform that provides an up-to-date server environment for hosting any modern Drupal version, BlackMesh’s WebOps experts have the knowledge and experience needed to guide you through the update process.

BlackMesh is the go-to provider for managing complex, high-functioning and secure web applications that meet the strict requirements. Our recent eBook explores the top 3 critical components of a successful Drupal application to ensure that your organization is maximizing the benefits of this open source CMS.

New call-to-action