Mediawiki notes on upgrading

From Bjoern Hassler's website
Jump to: navigation, search

1 Revised instructions: v.1.13 to v1.14[edit]

The instructions below were for update from from v 1.12 to v 1.13. With the upgrade of this wiki to v1.14, I've revised those. Nothing differs in principle - just slightly updated instructions.

This page explains how to upgrade a mediawiki. To do this, we go through the backup procedures quite carefully, so you may also be interested in this page if you just wish to backup a mediawiki.

Quick summary for backup is here: Mediawiki backup.

2 Lock the wiki[edit]

Lock the wiki http://www.mediawiki.org/wiki/Manual:$wgReadOnly

$wgReadOnly = 'site maintenance';

3 Backup your database / pages / wiki source[edit]

Backup at mediawiki.org: http://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki .

I've bundled some of these Instructions into a script: Mediawiki backup. If you're familiar with backing up a mediawiki, you can skip this section, and continue with the next section.

3.1 Backing up the database[edit]

(We assume you run mw on mysql.) Firstly, do a mysql backup. See options below.

3.1.1 Finding out whether your database is latin1[edit]

Once you have backed your database tables up (e.g. using mysql dump) you can look at the output from mysql dump to see what format your tables are in.

Alternatively, you can poke around your database:

mysql -u someuser -p
> STATUS;
> SHOW DATABASES;
> USE somewikidb;
> SHOW TABLES;
> SHOW CREATE TABLE sometable;
> quit

(Be sure to know what you are doing, so that you don't destroy your database! If in doubt, back up first!)

Look out for 'CHARSET'. If your charset is latin1, then follow the relevant procedures for backing up taking account of the charset, see http://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki .

3.1.2 Backing up your db[edit]

Here are some commands that you can use to back up your mediawiki db:

mysqldump -u root -p --all-databases  > MYSQL_BACKUP.txt
mysqldump -u root -p --all-databases --default-character-set=latin1 > MYSQL_BACKUP_latin1.txt
mysqldump -u root -p --all-databases --xml > MYSQL_BACKUP_XML.xml
mysqldump -u root -p --all-databases --xml --default-character-set=latin1 > MYSQL_BACKUP_XML_latin1.xml

(about the latin1 issue, see previous section)

In case you want to run something like this automatically: The Backing_up_a_wiki page recommends this for automatic backups

/usr/bin/nice -n 19 /usr/bin/mysqldump -u $USER --password=$PASSWORD $DATABASE -c 
  | /usr/bin/nice -n 19 /bin/gzip -9 > ~/backup/wiki-$DATABASE-$(date '+%Y%m%d').sql.gz

or

/usr/bin/nice -n 19 /usr/bin/mysqldump -u $USER -p$PASSWORD --default-character-set=$CHARSET $DATABASE -c \
  | /usr/bin/nice -n 19 /bin/gzip -9 > ~/backup/wiki-sql-$(date '+%a').sql.gz

You may also want to dump your pages, see below.

3.2 dump your pages as wiki text[edit]

Dump your pages.

As well as doing the mysql backup, you may want to dump your pages. From your wiki root directory, call

php  maintenance/dumpBackup.php 

for instructions.

php maintenance/dumpBackup.php --full | gzip > AllWikiPages.gz

Note that you must create an AdminSettings.php file with the right user and passwd, even if the default db user and passed set in LocalSettings.php has enough priviledges.

3.3 Backup your mediawiki install[edit]

Zip up the installed files from your 'wiki_source' directory, together with the mysql/page dumps, and keep them somewhere safe, in case something goes wrong.

4 Keep modified skins[edit]

For instance, if you are using the collection extension in mw 1.13, you'll have modified your monobook skin. Keep a copy of the modified files, so that you can redo those changes after the upgrade.

5 Upgrade[edit]

Upgrade, see http://www.mediawiki.org/wiki/Manual:Upgrading_MediaWiki . Get the code (e.g. for 1.14.0)

wget 'http://download.wikimedia.org/mediawiki/1.14/mediawiki-1.14.0.tar.gz'

Unpack the code - WARNING: This will overwrite modifications you've made to skins!!

tar xvfz mediawiki-1.14.0.tar.gz -C /path/to/your/wiki/ --strip-components=1

(I prefer this way to unpacking the mediawiki.tar.gz into a new directory: Like this, I don't need to move the uploaded images etc over.)

Now go to the maintenance dir, and run

php update.php --aconf ../AdminSettings.php

6 Finally[edit]

Re-enable the wiki.

Remove admin credentials from AdminSettings.php

Update extensions as needed.

7 Redo edits to skins[edit]

If you've made any edits to the skins, you'll now need to restore edits to skins. As of 1.14.0, you no longer need to modify MonoBook.php to work with the collection/book extension: The portlet can now be inserted by the extension into the skin.

8 Unlock the wiki![edit]

You're done!