Simplify WordPress Updates with Subversion

WordPress is already pretty easy to install and manage, but did you know that if you have command line access to your server, you can probably make that whole process a lot easier – especially when it comes to upgrades.

To install a fresh copy of WordPress in a directory named blog, follow these three steps.

$ mkdir blog
$ cd blog
$ svn co http://svn.automattic.com/wordpress/tags/2.6.3 .

You should then be able to follow the infamous 5 minute WordPress set-up procedure as normal. Next time a new version of WordPress is released (and there should be one out pretty soon) you only need to head to the command line and upgrade using the commands below.

$ cd blog
$ svn sw http://svn.automattic.com/wordpress/tags/2.7 .

This is the only thing you have to remember to do. Essentially, this command tells subversion to SWITCH the current install to the version with TAG 2.7.

That is all there is too it. There is no moving of files, no worrying about whether you will overwrite any of your changes, that is it. WordPress is updated to the latest version.

Plugins & Themes

But what about plugins and themes? Is there any way to keep them up-to-date in the same way? And the answer is of course, a resounding “Yes!”. Head on over to you blog directory and type the following commands.

$ cd wp-content/plugins/
$ svn propedit svn:externals .

A text editor should open up allowing you to specify where you want WordPress to find your plugins. This looks confusing but actually the svn:externals property is quite easy to understand. Essentially it tells subversion to take code from a given URL and put it in the specified directory. We can use this to ensure subversion keeps our plugins up to date.

You can add the relevant links to your plugins as needed. Each line represents a new directory. Give the local directory name e.g. “akismet” followed by a space and then the URL of the plugin repository. An example is given below.

akismet http://svn.wp-plugins.org/akismet/trunk/
permalink-redirect http://svn.fucoder.com/fucoder/permalink-redirect/
subscribe-to-comments http://svn.wp-plugins.org/subscribe-to-comments/trunk/

Once you have listed all your plugins, you simply run the following command whenever you want to bring them up to date.

$ svn update

This configuration is well documented and can easily be adapted to keep your theme up to date as well. However, the part I struggled with was finding the correct URLs for the plugins. The easiest solution is to fire up your browser and head over to: http://svn.wp-plugins.org/ where you can identify your plugin. Navigate to the “trunk” folder and the URL displayed in the address bar is the URL you need when editing svn:externals.

Further Help:
Installing/Updating WordPress with Subversion
WordPress SVN