Update wordpress using subversion

WordPress is one of the well know solutions for running your own blog and is maintained very actively. To keep the pace with the updates wordpress has an integrated updating mechanism which allows updating your installation directly from the administration backend.

In my case I did not like this because I used subversion to install wordpress. Using this method you can update your wordpress installation by switching to another tag in the SVN repository. In addition, this procedure makes sure that your individual changes made to the wordpress core are respected and you can merge the changes with the update.

Unfortunately I usually forget the update commands and so I wrote a small helper script in Perl that can be used for this task.

Download updateWordpress.pl

The source code

use strict;
use warnings;
# small helper update script because I always forget the command and URL
# of Wordpress' SVN repository
# use at your own risk. Coded by Thomas Westfeld, www.gorillapatch.com
# base url to wordpress subversion repository
my $base_url="http://core.svn.wordpress.org/tags/";
# validate user input
die "usage: updateWordpress.pl [version]\n" unless scalar(@ARGV) == 1;
die "no subversion repository found. cd into the wordpress directory first\n" unless (-d ".svn");
my $newVersion = $ARGV[0];
die "$newVersion is no valid version number" unless $newVersion =~ /\d+(.\d+)+/;
my $currentVersion =  &getCurrentVersion;
# confirm update from user
print "Do you really want to upgrade from current version $currentVersion to $newVersion [y/n]? ";
chomp (my $confirm = );
if (uc($confirm) eq 'Y') {
    system ("svn sw ${base_url}${newVersion} .");
} else {
    print "update cancelled\n";
    exit 1;
exit 0;
# use svn info to get the URL of the currently checked out tag
sub getCurrentVersion
    my $result;
    open my $version_fh, "-|", "svn info";
    while (my $line = <$version_fh>) {
        if ($line =~ /^URL: $base_url([0-9.]+)/) {
            $result = $1;
    close ($version_fh);
    return $result;


Chemist, Programmer, Mac and iPhone enthusiast. Likes coding in Python, Objective-C and other languages.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.