Bash scripts to streamline the Drupal core and module update process via Subversion
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:
- Download core and module updates tarballs
- Unpack the update over a local SVN working copy
- Test and commit the updates locally
- 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:
- Moves the core update package to tmp and unpacks it.
- Removes the .htaccess and sites/example.sites.php files.
- Zips the modified core package and unpacks over the local install.
- SVN adds any new files.
- Pauses and prompts you to run update.php locally and test.
- Checks in the modified and new files upon confirmation.
- Prompts to run SVN update against the remote installation.
drupal_module_update.sh does the following:
- Moves the module update package to either sites/all/modules or sites/yourdomain.com/modules and unpacks it.
- SVN adds any new files.
- Pauses and prompts you to run update.php locally and test.
- Checks in modified and new files upon confirmation.
- 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
- Clone the Git repo or Download (tar.gz or zip)
- Remove the .default extension froma drupal_info.sh
- 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.
- 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.