Update wordpress using subversion

Word­Press is one of the well know solu­tions for run­ning your own blog and is main­tained very active­ly. To keep the pace with the updates word­press has an inte­grat­ed updat­ing mech­a­nism which allows updat­ing your instal­la­tion direct­ly from the admin­is­tra­tion backend.

In my case I did not like this because I used sub­ver­sion to install word­press. Using this method you can update your word­press instal­la­tion by switch­ing to anoth­er tag in the SVN repos­i­to­ry. In addi­tion, this pro­ce­dure makes sure that your indi­vid­ual changes made to the word­press core are respect­ed and you can merge the changes with the update.

Unfor­tu­nate­ly I usu­al­ly for­get the update com­mands and so I wrote a small helper script in Perl that can be used for this task.

Down­load 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.