Bash scripts to streamline the Drupal core and module update process via Subversion

Filed under

Drupal is a great foundation for so many types of web sites. The Drupal community continuously improves its core and the growing list of add-on modules to extend functionality and improve security. If you manage several Drupal sites, all of this extending and improving can make keeping Drupal up-to-date a time-consuming task. Here are a few notes about how I maintain my Drupal and a few shell scripts I've created to streamline the process.

Drupal Multisite and Subversion

I use Drupal's multisite feature and Subversion to create and manage almost every site I develop.

Here's the basic process:

  1. Download core and module updates tarballs
  2. Unpack the update over a local SVN working copy
  3. Test and commit the updates locally
  4. Run SVN update for the remote production copy

About a year ago, I wrote a few shell scripts to streamline this process for Drupal 6 and recently added support for Drupal 7.

Drupal Core and Module Update Scripts

Before using the update Drupal core script, be sure that you've set your Subversion repository to ignore
local files that you don't want to add (i.e. settings.php, symlinks, etc.). If you don't, the script may add and commit files you don't want in your repo. With that out of the way, here are the scripts and a what they do.

drupal_update.sh does the following:

  1. Moves the core update package to tmp and unpacks it.
  2. Removes the .htaccess and sites/example.sites.php files.
  3. Zips the modified core package and unpacks over the local install.
  4. SVN adds any new files.
  5. Pauses and prompts you to run update.php locally and test.
  6. Checks in the modified and new files upon confirmation.
  7. Prompts to run SVN update against the remote installation.

drupal_module_update.sh does the following:

  1. Moves the module update package to either sites/all/modules or sites/yourdomain.com/modules and unpacks it.
  2. SVN adds any new files.
  3. Pauses and prompts you to run update.php locally and test.
  4. Checks in modified and new files upon confirmation. 
  5. Prompts to run SVN update against the remote installation.

I still have several features I'll be adding, including the use of drush to run database updates (update.php) and the removal of deprecated files. See the Roadmap for a full to do list.

Get the scripts, Configure 'em, and Use

  1. Clone the Git repo or Download (tar.gz or zip)
  2. Remove the .default extension froma drupal_info.sh
  3. Edit drupal_info.sh, add local and remote path information for your Drupal 6 and 7 instance. Add SSH server and username for remote server.
  4. Download Drupal core/module updates to $DownloadsPath, the following to update a Drupal core:

    % drupal_update.sh

    or, update a shared or site-specific module with:

    % drupal_module_update.sh
    

Roadmap

  • Delete deprecated package files from SVN via svn remove.
  • Provide drush integration to initiate update.php, etc.
  • Cleanup and release a "create new multisite instance" script.
  • Add theme update/install support.

Change Log

2011-02-11 version 0.8

  • Added support for Drupal 7.
  • Auto-detect version.
  • Automatically add new files for Drupal core updates.
  • Fix include of drupal_info.sh to allow aliased script execution to work.

Share