Using CVS to maintain a Drupal website

Last modified: August 19, 2009 - 00:59

Why maintain a site from CVS?

Maintaining a site from CVS helps in two main areas:

  1. Upgrades: Normally, when it comes time to upgrade Drupal to a new version, there's a long list of upgrade steps that you need to follow. New tarballs need to be downloaded and extracted not only for Drupal core, but for all contributed modules as well. Repeat for each Drupal site you maintain. With CVS, this is just a single command.
  2. Access to bug fixes: New releases of Drupal are only made after major bugs (generally security issues) are fixed. These bugs (along with dozens of smaller bugs) are always fixed in CVS first.

How to maintain a site using CVS

Assuming you've already grabbed the core code and your favorite contrib modules using the instructions on the checking out core from CVS and checking out contrib modules from CVS pages, you can update your files at any time using a couple of CVS commands.

Checking for updates to core and contribs

cvs -nq update -dP

If updates are available, this will display output similar to:

U modules/taxonomy/taxonomy.module
U modules/upload/upload.module

The 'U' means that the listed file is newer, or "updated" from the one you have in your local copy.

Updating the site

To pull in the changes from CVS that will update your site to the latest Drupal "HEAD" version and dev versions for contributed modules:

  1. Enter the command:
    cvs update -dP

    This will update your site to the latest development versions of Drupal core and contributed modules.
  2. While logged in as user/1, navigate to example.com/update.php to launch the database update utility to pick up any database changes.

Upgrading to a specific version of Drupal

Your installation must have been installed via CVS in order to upgrade it via CVS. Let's say you'd like to upgrade from Drupal 6.6 to 6.8. (This will only update Drupal core, not contributed modules):

  1. Enter the command:
    cvs update -r DRUPAL-6-8 -dP
  2. While logged in as user/1, navigate to example.com/update.php to launch the database update utility to pick up any database changes.

Note that if you are doing a major release upgrade (e.g. from Drupal 4.7 to 5.x or from Drupal 5.x to Drupal 6.x) you need to check on your contributed modules to make sure they have been ported for that major version of Drupal.

Upgrading to a specific version of a Drupal contributed module

You can upgrade contributed modules to a specific version if those modules were installed via CVS:

  1. Navigate to the directory at the root level of the contributed module.
  2. enter the command:
    cvs update -r DRUPAL-5--1-4 -dP

    where DRUPAL-5--1-4 is the "CVS Tag" as listed on the release notes for the module.
  3. While logged in as user/1, navigate to example.com/update.php to launch the database update utility to pick up any database changes.

Note: Core tags differ slightly from contribution tags. See Overview of core branches and tags and Overview of contribution branches and tags

Tips

  • Having a test site is highly recommended; new changes from CVS could potentially bring in additional bugs or changes which break your site (particularly with contributed modules). Testing these updates on a copy of your live server before moving them over is a great idea.
  • Using a version control system for your Drupal code such as CVS or Subversion is also a good idea; this way, you can keep track of what changes were made and when.
  • The CVS deploy module is useful for printing more user-friendly version strings on the system modules page, and for interacting with the Update status module (included in core in 6.x and beyond, and via a contributed module for 5.x).
 
 

Drupal is a registered trademark of Dries Buytaert.