Orange is my favorite color

Wordpress is really best suited to a single install per instance. Although there are guides to hack multiple instances from a single core install, it gets messy quick and usually relies on a lot of fragile symbolic links. Yuck. Wordpress MU is also an option but since I already have multiple installs for multiple blogs (the most common method), I’m running with it.

As a result of keeping them separate, I have seven Wordpress installs that need updating whenever security fixes or major releases come out. One of the ways to make this easier is to manage your install with Subversion. It’s straightforward and took about 10 minutes per install to convert my blogs.

To further automate this process growing list of installs, I wrote this short shell script to update all of my instances at once:

#!/bin/bash
if [ $# -ne 1 ]; then
         echo 1>&2 Usage: $0 wordpress_version_tag
         exit
fi

echo "Upgrading Wordpress to $1..."

DIRS=(/path/to/site1 /path/to/site2 /another/path/to/site /some/other/website )

for dir in ${DIRS[@]}
do
    echo "Upgrading $dir to $1..."
    svn sw http://svn.automattic.com/wordpress/tags/$1/ $dir
done

Here’s some abbreviated output from upgrading to 2.6.5 a few minutes ago:

[[email protected] system]$ ./upgrade_wordpress.sh 2.6.5
Upgrading Wordpress to 2.6.5...
Upgrading /websites/dancehallcrashers.com/ to 2.6.5...
U    /websites/dancehallcrashers.com/wp-includes/post.php
U    /websites/dancehallcrashers.com/wp-includes/version.php
U    /websites/dancehallcrashers.com/wp-includes/feed.php
U    /websites/dancehallcrashers.com/xmlrpc.php
U    /websites/dancehallcrashers.com/wp-admin/users.php
Updated to revision 9904.
Upgrading /websites/ghidinelli.com/ to 2.6.5...
U    /websites/ghidinelli.com/wp-includes/post.php
U    /websites/ghidinelli.com/wp-includes/version.php
U    /websites/ghidinelli.com/wp-includes/feed.php
U    /websites/ghidinelli.com/xmlrpc.php
U    /websites/ghidinelli.com/wp-admin/users.php
Updated to revision 9904.
Upgrading /websites/ghidinelli.com/go/ to 2.6.5...
U    /websites/ghidinelli.com/go/wp-includes/post.php
U    /websites/ghidinelli.com/go/wp-includes/version.php
U    /websites/ghidinelli.com/go/wp-includes/feed.php
U    /websites/ghidinelli.com/go/xmlrpc.php
U    /websites/ghidinelli.com/go/wp-admin/users.php
Updated to revision 9904.

Easy! To use this script after converting your installs to subversion, just:

  1. Create this script as upgrade_wordpress.sh anywhere on your Unix server
  2. chmod +x upgrade_wordpress.sh – make it executable
  3. ./upgrade_wordpress.sh 2.6.5 – update all of your instances at once

The nice thing is you can also downgrade in case something goes wrong by specifying a lower version number. And subversion won’t mess with your custom files like themes, uploads or plugins.

When I upgrade a minor version (2.6.3 to 2.6.5 for example), I usually don’t bother with backups or disabling plugins (I know, shame on me). For major version updates (2.5 to 2.6 or 2.6 to the coming 2.7), I would at least back up my database first and might disable my plugins.

Remember that after a major update, you typically need to log in to the admin section for each blog to run the upgrade script!

1 Comment

  1. This is Tyler Fitch » Blog Archive » links for 2008-12-19 said:

    on December 19, 2008 at 10:30 pm

    [...] Orange is my favorite color » Blog Archive » Upgrading many Wordpress installs at once from subver… (tags: wp wordpress upgrade) [...]

{ RSS feed for comments on this post}