work, life & chinese
Random header image... Refresh for more!

Simplify Wordpress Updates with Subversion

November 8, 2008
 

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

Related posts:

  1. Blog Updates
  2. Wordpress 2.0
  3. Wordpress on the iPhone

13 Responses to “Simplify Wordpress Updates with Subversion”

  1. John says:

    Cool stuff!

    I use DreamHost, and upgrade all my WordPress installs through their custom control panel's “one-click update” feature. This does sound much more difficult, though.

    Two questions, though:

    How standard is Subversion, or how difficult to install? Can subversion get around issues of direct code mods/hacks being overwritten?

  2. John says:

    Oops… “doesn't sound much more difficult.”

  3. Bill says:

    @John - Subversion is very standard - when you get that new MacBook it will come with Subversion already installed. The question for you though is whether your hosting provider supports Subversion.

    I’ve had a quick look at DreamHost (http://www.dreamhost.com/hosting-features.html) and it appears they provide full access to Subversion. They also allow you to host unlimited subversion repositories.

    As for the second question, the answer is yes and no. If you have modified the Wordpress code then the update process is always going to be more involved. However, I have found that it is generally possible to do all my Wordpress customisation by creating plugins and/or theme modifications. If I use subversion to manage these modifications I can then use the method above to update them just like any other Wordpress.org hosted plugin.

    If you are going down this route then you probably want to read up a bit more about subversion and the way it works. I suggest the very good Subversion Book.

  4. John says:

    Thanks for the reply! I have only recently started using my DH shell account, not because I don’t know how (I was raised on DOS and batch files, so unix isn’t too mystifying), but because I never had much reason to. This could give me one more reason.

    I’m no programmer, so I don’t do any extensive changes to the WP core code or anything ridiculous like that. I just like to use my custom version of the javascript quicktags file (I don’t use rich text formatting), and it’s annoying that it’s always being overwritten when I upgrade…

  5. Bill says:

    @John - Unless I’m missing a trick, subversion would attempt to merge the updated quicktags.js with your modified copy. Without trying it I wouldn’t want to speculate as to the results.

    There are a couple of plugins that allow you to add quicktags to the editor and I’m assuming that these would do so without modifying the quicktags.js file directly.

    These pages should give more information:

  6. 盛荣祖 says:

    WOW!比尔你写的这是什么?

  7. Nick Carter says:

    I’ve taken to updating my theme via subversion but haven’t, as yet, started grabbing the app itself that way. Dunno why. May do so soon!

    Thanks for a nice little read!

  8. Ryan says:

    Bill, cool stuff. Will definitely start upgrading WP versions using SVN - have used it a few times for development reasons, and so this should be pretty simple to get into the habit of.

    Though, I don’t know if upgrading plugins this way makes much sense when you can upgrade them automatically (and quickly) via WordPress’ backend.

  9. Bill says:

    @Ryan - Thanks for dropping by. If I remember correctly, the automatic upgrade process for plugins requires you to have FTP access to your server. Whilst I could install it, it isn’t something I really want to do.

    Before starting to manage your blog using subversion, I definitely recomend looking at the automatic upgrade of the core code that will be available in 2.7. I haven’t decided yet if I’m going to continue using subversion or go with the new updater. I’ll be sure to post again when I reach a decision.

  10. Nick Carter says:

    @Bill - The WordPress Upgrader does sound pretty attractive - much like the existing plugin upgrader. I doubt I’ll ever turn on automatic upgrades, but it’s an excellent addition!

    I noticed the markdown plugin was listed as a file to be deleted with each upgrade, I hope it gets replaced with the new one and not simply deleted, as I’ve started using it recently!

    Thanks for pointing this out!

  11. Bill says:

    @Nick Carter - I too have my doubts about the automatic updater but from what I have read it works well. I’d have to fully understand how it works and what file permissions are required before I turn it on.

    I haven’t used to markdown plugin before, but it looks like something worth trying. Thanks for the heads up.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>