Wednesday, October 24, 2007

Using CVS to maintain a Drupal website

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

Note: For detailed explanation and further examples of CVS commands, see the Main repositoryContributions repository pages. and

Step 1: Check out code from CVS

Let's say, for example, you wanted to build a Drupal 5.2 site with the CCK and Views modules:

cvs -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal checkout -r DRUPAL-5-2 -d mysite drupal
cd mysite
cvs checkout -d sites/all/modules/views -r DRUPAL-5-2 contributions/modules/views
cvs checkout -d sites/all/modules/cck -r DRUPAL-5-2 contributions/modules/cck

Step 2: Checking for updates

You can check for updates at any time by issuing the command:

cvs -nq update -dP

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

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

Step 3: Updating the site

To pull in the changes from CVS:

  1. Enter the command:
    cvs update -dP

    This will update your site to the latest Drupal core and contributed modules.
  2. Run update.php to pick up any database changes.

Upgrading to the next version of Drupal

Let's say you'd like to upgrade from Drupal 5.2 to 6. Basically, the steps are the same except you'll need to research which contributed modules have been ported to the version of Drupal, and take steps to port those that are not. Failing to do so could break your site. To check for

  1. Enter the command:
    cvs update -r DRUPAL-5 -dP
  2. Run update.php to pick up any database changes

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.
Original Post: http://drupal.org/node/93966

No comments: