HOWTO backup and install the GlueX wiki

From GlueXWiki
Jump to: navigation, search

Here are instructions for backing up the GlueX wiki and reinstalling it at another location. This was originally motivated by the ongoing US Federal Government shutdown of 2013 that may cause JLab to close temporarily. To avoid complete disruption to the collaboration, we were preparing to move it to the URegina server temporarily. Since then, it turns out this is useful in preparing to upgrade the wiki. It is recommended to execute this procedure on a separate computer first and update the page with any changes. This should make the upgrade to the live wiki smoother and less risky since major incompatibilities might be identified ahead of time.


Technical details

The GlueX wiki uses MediaWiki with a MySQL database for the backend. The wiki is hosted at JLab with these settings:

  • Web Server = halldweb1.jlab.org
  • MySQL Server = cnidb.jlab.org
  • dbname = halldwikidb
  • mysql user = halldwiki
  • mysql password = ??


Backing up the wiki

Use the script: https://halldsvn.jlab.org/repos/trunk/scripts/backup_wiki

Restoring the wiki

Before starting, you'll need to get your PHP-enabled web-sever up and running as well as you MySQL database. Once those are working, go to the directory where the wiki pages will be served from and follow these steps:

Unpacking the files

1. Unpack MediaWiki

> tar xzvf mediawiki-1.22.5.tar.gz

2. Rename "mediawiki-X" directory to "wiki"

> mv mediawiki-1.22.5 wiki

3. Unpack tarball from GlueX wiki backup

> tar xzvf wiki_backup_14-04-18.tgz

4. Move files from backup directory into wiki directory

> cp -rp wiki_backup_14-04-18/* wiki

5. You may need to change permissions on the images directory (and subdirs) so that the web server can add and modify files there.

> chmod -R o+w wiki/images

6. Adjust the top-level directory name in LocalSettings.php if needed. This is the directory relative to the root directory the webserver will use to serve up pages. If you install the "wiki" directory in the top-level directory then you don't need to change anything. On my laptop however, the wiki was being served out of ~davidl/wiki so I had to modify the value of the $wgScriptPath to be this:

$wgScriptPath	    = "/~davidl/wiki";

Extensions

Occasionally, we install extensions to the wiki. These may also need to be updated to stay in sync with the wiki version. It also turns out that some extensions are now distributed with MediaWiki itself. Look at the bottom of the LocalSettings.php file for which extensions are actually enabled. A record of these *should* be kept in the README.JLab file that is copied into the back directory:

>less wiki_backup_14-04-18/README.JLab

The extensions directory is copied into a directory called extensions.JLab in the backup. If you're being diligent (and I know you are) then you'll download compatible versions of any extensions that are not already present in the new wiki's extensions directory. The extensions in the backup can be used as a last resort, but there is some risk to doing that so avoid it if possible.

Filling the Database

Prior to filling the database, you need to make sure you have an account there that the webserver can write to.

1. Edit the file wiki/LocalSettings.php to set the connection parameters for the database (look for the string wgDBserver). For example, to install this on my laptop I changed this :

#$wgDBserver         = "halldweb1.jlab.org";
$wgDBserver         = "cnidb.jlab.org";
$wgDBname           = "halldwikidb";
#$wgDBname           = "wikidb";
$wgDBuser           = "halldwiki";
#$wgDBuser           = "wiki";
$wgDBpassword       = "wiki";
$wgDBprefix         = "gluex_";
$wgDBtype           = "mysql";

to this

$wgDBserver         = "127.0.0.1";
$wgDBname           = "halldwikidb";
$wgDBuser           = "halldwiki";
$wgDBpassword       = "";
$wgDBprefix         = "gluex_";
$wgDBtype           = "mysql";

2. Drop the existing database from the server if it already exists. Don't bother to recreate it since it will be automatically created by commands in the halldwikidb.sql file in the next step.

> mysql -u halldwiki
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.43 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop database halldwikidb;
mysql> quit

3. Fill the database using the wikidb.sql file

>mysql -u halldwiki < halldwikidb.sql


4. Run the upgrade script in order to update the DB tables

>php maintenance/update.php

Troubleshooting

No images

When I first installed the wiki on my laptop (Macbook Pro, OS X 10.7.5) the images would not come up and I could see this message in the error log:

>tail /var/log/apache2/error_log
[Sat Oct 12 20:19:55 2013] [error] [client fe80::1] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /Users/davidl/Sites/wiki/images/thumb/8/80/Gluex-eng1.png/300px-Gluex-eng1.png, referer: http://localhost/~davidl/wiki/index.php/Main_Page

After some head scratching and web searching, it turns out the problem is due to some reduced permissions being set in a .htaccess file in the images directory. This file looks to be distributed with MediaWiki to address a security bug. The solution was found here which said to add a "Options FollowSymLinks" line to the .htaccess file. Here's what mine looked like after I added it and images started working:

# Protect against bug 28235
<IfModule rewrite_module>
	Options FollowSymLinks
	RewriteEngine On
	RewriteCond %{QUERY_STRING} \.[^\\/:*?\x22<>|%]+(#|\?|$) [nocase]
	RewriteRule . - [forbidden]
</IfModule>