A few weeks ago, Alan wrote about how to find out if your Drupal and Wordpress sites are up to date. So, what if you find out your Drupal site is horribly out of date - core, modules and all? What then?
If you run the script Alan wrote about, or you simply notice the alert in the admin section of your site notifying you that your site has updates available, most of the time you'll want to implement at least some of these updates.
Image may be NSFW.
Clik here to view.
Note: The notice for updates is powered by a module called Upgrade Status. It's a good idea to install this module on your Drupal site so you don't let updates go by the wayside.
When you see the update notice, click “available updates” and see which updates are necessary. You can also reach this page by going to admin/reports/updates in your browser (for example, www.yoursite.com/admin/reports/updates).
The updates page will display which version of Drupal you are running as well as the recommended version of Drupal, and the same for each contributed module running on your site. If something is highlighted in green, it is up to date; yellow means there is an update but it’s not critical; red means you should update right away.
Image may be NSFW.
Clik here to view.
So, how do you update Drupal Core and contributed modules?
Generally, if your site is hosted with EchoDitto and/or you have a technical retainer with us, we will inform you of any critical updates and estimate the time needed to implement these updates. If you are hosting outside of EchoDitto or do not have a technical retainer, however, what follows is a step-by-step guide for updating your Drupal site safely and efficiently.
Note: As always, it's a good (read:great) idea to have a development site, separate from your live public-facing site. This should be used for any testing purposes, including updating Drupal core and modules. You should always do updates and testing on your development site first, before ever touching your live site.
In addition, it is always best to have a developer on your team take care of updating your site. Generally, site updates are tech-heavy, and require intimate knowledge of version control systems and database configurations.
My preferred method for updating modules and Drupal core is via Drush.
You’ll find a few possible ways of updating your modules and Drupal core below. I generally think you should follow whichever steps are appropriate depending on your knowledge of the tools at hand. Keep in mind the following steps are for updating on a development site only. For the purposes of this post, I'll go through the following scenarios:
- Updating via Drush (with svn)
- Updating via Drush (without svn)
- Updating manually (with svn)
- Updating manually (without svn)
- Updating on your live site
Updating via Drush (with svn)
- Change to the root of your Drupal install
- Back up your database
- Run 'drush upc --version-control=svn --svnsync'. 'drush upc' updates all contributed modules, without running update.php OR updating core
- Update core: run 'drush up'
- Run 'drush updb' to update your site locally.
- Test locally before committing to your development site.
- Add any new files and commit your changes. Use 'svn add --force *' to force the addition of all new files.
- Use 'svn commit' to commit your changes.
- Run 'drush updb'
- Test
Updating via Drush (without svn)
- Back up your database
- Run 'drush up' or 'drush upc'
- Run 'drush updb' - this will run update.php
Notes:
- The 'drush up' command updates modules, core, and runs update.php
- The 'drush upc' command updates modules only, and does not run update.php
Updating manually (with svn)
- Back up your database
- Download the new version of the module from drupal.org
- 'svn remove' the old module file ('svn rm sites/all/modules/modulefolder')
- 'svn commit'
- Extract the new module and place it in sites/all/modules
- 'svn add' the new module folder
- 'svn commit'
- Run update.php. Do this by going to www.yoursite.com/update.php
- Test, test, test
Updating manually (without svn)
- Back up your database
- Download the new version of the module from drupal.org
- Delete the old module directory, and replace it with the new downloaded copy
- Run update.php. Do this by going to www.yoursite.com/update.php
- Test, test, test
Updating on your live site
- Back up your database.
- Put the site into maintenance mode. You can find that setting at /admin/settings/site-maintenance and select “Off-line.” Customize your offline message as appropriate.
- Update modules and core (following whatever steps you followed above: drush (with or without svn), svn, or manually).
- Run update.php. Do this by going to www.yoursite.com/update.php.
- Test.
- Take the site out of maintenance mode.
- Test more.
Want more info? Here are some helpful links:
- Drush: http://drupal.org/project/drush
- Subversion: http://subversion.apache.org/
- Coder: http://drupal.org/project/coder
- Tutorial: http://www.lullabot.com/videos/porting-drupal-modules