Skip to content


MediaWiki automated upgrade script

Last week-end, I finally took the time to upgrade Wiki4Games to MediaWiki 1.15.4. We’d been running it on 1.15.2 since, hm, a long time ago and never moved to 1.15.3 because the security issues fixed weren’t too big and wouldn’t affect members using things like the NoScript Firefox extension. 1.15.4 added extra fixes in the same field, but since the potential troubles included the possibility to change an imprudent user’s password, I thought it was time to do the update. Usually for minor updates I use the .patch file, but since 1. the patch file was a bit bigger than usual ; 2. I would need to apply two patches (1.15.3 then 1.15.4) ; and 3. MediaWiki 1.16 is on its way and should arrive “soon”, I thought it would be a good idea to finally (Wiki4Games was created more than 2 years ago, under MediaWiki 1.12.x) make an upgrade script. And here it is:

cd /home/wiki4games
wget http://download.wikimedia.org/mediawiki/1.15/mediawiki-1.15.4.tar.gz
tar xf mediawiki-1.15.4.tar.gz
mv wwwOLD wwwOLD2
mv mediawiki-1.15.4 wwwNEW

echo "Cleaning up wwwNEW (removing extensions and images folders)"
rm wwwNEW/images/README
rmdir wwwNEW/images
rm wwwNEW/extensions/README
rmdir wwwNEW/extensions
mv www/.htaccess www/.temphtaccess
cp sd/down/.downhtaccess www/.htaccess

mv www/00files wwwNEW
mv www/0custom wwwNEW
mv www/extensions wwwNEW
mv www/images wwwNEW
mv www/skins/0custom wwwNEW/skins
cp www/404.php wwwNEW
cp www/AdminSettings.php wwwNEW
cp www/LocalSettings.php wwwNEW
cp www/.temphtaccess wwwNEW
mv www wwwOLD
mv wwwNEW www
cd www/maintenance
php update.php
cd ../..
rm www/.htaccess
mv www/.temphtaccess www/.htaccess

echo "All done. You can also delete wwwOLD2, www/config and www/docs"

Of course, to apply it to your own MediaWiki installation, you’ll need to do some customization. Let’s give some explanations:

cd /home/wiki4games
We move to the directory just higher than where MediaWiki is installed.

wget http://download.wikimedia.org/mediawiki/1.15/mediawiki-1.15.4.tar.gz
tar xf mediawiki-1.15.4.tar.gz

We download and uncompress MediaWiki 1.15.4.

mv wwwOLD wwwOLD2
wwwOLD is a folder where I keep the previous version, so we move it to wwwOLD2 to free the wwwOLD name (that’s where we’ll move the current installation). wwwOLD2 can be deleted manually at the end of the process. I chose not to place any kind of rm -r command in this script, which is why I don’t delete wwwOLD but rename it instead.

mv mediawiki-1.15.4 wwwNEW
We move MediaWiki to a folder with a more friendly name.

echo "Cleaning up wwwNEW (removing extensions and images folders)"
rm wwwNEW/images/README
rmdir wwwNEW/images
rm wwwNEW/extensions/README
rmdir wwwNEW/extensions

We remove the extensions and images folders from the standard installation, so that we can later move our own extensions and images folder in their place. To do so we first need to remove all files inside them, which means the README files.

mv www/.htaccess www/.temphtaccess
cp sd/down/.downhtaccess www/.htaccess

Here I replace the production .htaccess file with a maintenance one. Our maintenance .htaccess file redirects all trafic to down.wiki4games.com/maintenance.htm, but you can use one which just denies all access (order allow, deny; deny from all). The important thing here is that noone loads the wiki during the sensitive moves (this will result in a very short down time, hardly noone will notice it, it’s just the time needed to move some folders around… plus to apply the database patches, which might be a bit longer from a major version to another).

mv www/00files wwwNEW
mv www/0custom wwwNEW
mv www/extensions wwwNEW
mv www/images wwwNEW
mv www/skins/0custom wwwNEW/skins
cp www/404.php wwwNEW
cp www/AdminSettings.php wwwNEW
cp www/LocalSettings.php wwwNEW
cp www/.temphtaccess wwwNEW

We move the big things and copy the small individual files.

mv www wwwOLD
mv wwwNEW www

The current MediaWiki becomes OLD, the NEW one becomes current.

cd www/maintenance
php update.php

We run the maintenance database update script. On a large wiki, this may take a while (unless there is no database scheme change).

cd ../..
rm www/.htaccess
mv www/.temphtaccess www/.htaccess

And we restore the original .htaccess, the new wiki is opened 🙂 If you got no error message during the script, it’s probably up and working. If you did get error messages, you can still check if it works but you’ll probably need to do some fixing.

echo "All done. You can also delete wwwOLD2, www/config and www/docs"
Those are useless folders, but I didn’t place a removal command for them in the script because I didn’t want to use rm -r.

Posted in MediaWiki.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA