Mediawiki maintenance

From Biowikifarm Metawiki
Revision as of 21:07, 8 November 2010 by Gregor Hagedorn (Talk | contribs)

Jump to: navigation, search

(See also a quick introduction to the Mediawiki setup)

Mediawiki maintenance scripts

(See http://www.mediawiki.org/wiki/Manual:Maintenance_scripts)

In /usr/share/mediawiki/phase3/ copy AdminSettings.sample to AdminSettings.php, create a new user wikiadmin for mysql with localhost only, and edit AdminSettings.php accordingly. Then, for each wiki, in /var/www/wikifolder/, a symlink must be created linking to /usr/share/mediawiki/phase3/AdminSettings.php. Since we have a symlinked installation, installations scripts must run like:

 php /var/www/wikifolder/maintenance/rebuildall.php   --conf /var/www/wikifolder/LocalSettings.php
 php /var/www/wikifolder/maintenance/importImages.php --conf /var/www/wikifolder/LocalSettings.php /var/www/wikifolder/media/newimages .jpg .png .svg

Rebuild all is necessary after external text, sql, or xml imports.

Table corruption: rebuildall.php may report that a table, especially searchindex (which is MyISAM even if other tables are InnoDB) is corrupt and needs to be repaired. In phpmyadmin, open a sql window for the affected database, and issue: truncate table searchindex;. Running rebuildall.php afterwards concluded the repair in a case we had.

Rebuilding the file cache (note: permission may be a problem; this will be the commandline user, whereas normally cache is written by apache):

 cd /var/www/metawiki;       php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/testwiki;       php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/v-k2n/w;        php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/v-k2n/it;       php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/v-lias/w;       php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/v-phytomed/w;   php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/v-phytopathology/w; php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/v-rosaceae/w;   php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/v-species/n;    php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/v-species/o;    php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/v-species/w;    php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php
 cd /var/www/v-workbench/w;  php ./maintenance/rebuildFileCache.php 0 overwrite --conf ./LocalSettings.php

After erroneously localizing commons images not to openmedia but to local wikis, extension Nuke was used to deleted the caching-bot imports, and deleteArchivedFiles to actually delete all archived files:

 cd /var/www/v-onf/w; php ./maintenance/deleteArchivedFiles.php  --conf ./LocalSettings.php --delete

Fix problems with unparsable image names (see [1]):

 cd /var/www/v-k2n/w; php ./maintenance/cleanupImages.php --fix  --conf ./LocalSettings.php
 cd /var/www/v-onf/w; php ./maintenance/cleanupImages.php --fix  --conf ./LocalSettings.php
 cd /var/www/v-species/o; php ./maintenance/cleanupImages.php --fix  --conf ./LocalSettings.php
 cd /var/www/v-species/s; php ./maintenance/cleanupImages.php --fix  --conf ./LocalSettings.php

Extension maintenance scripts

Some extensions provide their own maintenance scripts in their own extension folder. On a wiki farm, the execution of these scripts may fail due to the linked directory structure. They need an additional link (needs to be created only once):

 cd /usr/share/mediawiki/; ln -s /usr/share/mediawikistaging/phase3/maintenance
 cd /usr/share/mediawikistaging/; ln -s /usr/share/mediawikistaging/phase3/maintenance

TitleKey now installed:

 cd /var/www/testwiki; php ./extensions/TitleKey/rebuildTitleKeys.php --conf ./LocalSettings.php

MediaWiki version upgrading

To upgrade Mediawiki first run the update on the staging version (= testwiki, http://biowikifarm.net/test):

 cd /usr/share/mediawikistaging/; sudo svn update phase3 extensions  -r59858
 sudo /usr/sbin/apache2ctl -k graceful
 # Optionally add other updates:
 sudo apt-get update
 sudo apt-get upgrade
 cd /usr/share/; sudo svn update phpmyadmin-dev

After testing and verifying functionality, also update the production version (where "-r52502" indicates to update precisely to revision 52502; this should always be the value of the tested revision from staging / test wiki!):

 cd /usr/share/mediawiki; sudo svn update phase3 extensions  -r66620
 sudo /usr/sbin/apache2ctl -k graceful

WARNING: AS OF 2010-09-07, SEMANTIC FORMS IS PATCHED AND WILL NOT UPGRADE ANY LONGER!!!
See /usr/share/mediawiki/extensions/SemanticForms/includes for note on which file is patched.

NOTE: [Bug 21199] fatal error in MultiUpload in combination with mw 1.16.r57940 https://bugzilla.wikimedia.org/show_bug.cgi?id=21199 Marking this as fixed as per r76108 and r76109 (and my follow-up revision, r76115). -- TRY EXTENSION AGAIN ONCE 76115 goes into service on biowikifarm!

Occasionally the SVN upgrading of Mediawiki may require an upgrade of the database structures. Again, the update.php must be called with symlink-compatible syntax. Examples for mediawiki core:

 cd /var/www/metawiki; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/testwiki; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-on/w;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-ispi/w;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-k2n/w;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-k2n/h;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-k2n/it;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-lias/w;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-phytomed/w; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-phytopathology/w; php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-rosaceae/w;  php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-species/n;   php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-species/o;   php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-species/s;   php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-species/w;   php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-species/f;   php ./maintenance/update.php  --quick --conf ./LocalSettings.php
 cd /var/www/v-workbench/w; php ./maintenance/update.php  --quick --conf ./LocalSettings.php


For semantic mediawiki extension (SMW) click on "Initialise or upgrade tables" on SpecialPage Semantic Admin:

See also Maintenance scripts above for further scripts.


Adding a new directory link

Occasionally new directories directly in /phase3/ are introduced by mediawiki.org with version upgrades. New symbolic links need to be created:

# root wiki from staging:
cd /var/www/testwiki/; sudo ln -s /usr/share/mediawikistaging/phase3/resources/ resources
cd /var/www/wiki-template-staging/; sudo ln -s /usr/share/mediawikistaging/phase3/resources/ resources
# root wikis from normal:
cd /var/www/metawiki/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/studienstiftungswiki/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/wiki-template/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
# virtual servers
cd /var/www/v-ispi/w/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-k2n/w/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-k2n/h/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-k2n/it/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-lias/w/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-on/w/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-phytomed/w/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-phytopathology/w/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-rosaceae/w/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-species/w/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-species/f/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-species/o/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-species/s/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-species/u/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources
cd /var/www/v-workbench/w/; sudo ln -s /usr/share/mediawiki/phase3/resources/ resources

(To remove links one may use the interactive option rm -i, but one must confirm each single file.)

General topics

MediaWiki configuration tips

Configuring MediaWiki:Sidebar: New options July 2008, see [2]

It may be useful to copy the contents of http://en.wikipedia.org/wiki/MediaWiki:Common.css and http://en.wikipedia.org/wiki/MediaWiki:Monobook.css into the Mediawiki:Common.css and MediaWiki:Monobook.css pages of each Wiki where you may want to use copied things e.g. templates from wikipedia.

File uploading and Mime types

Uploading files with extensions and Content types (MIME types) usually not allowed on wikis: The default of normally allowed extensions is listed $wgFileExtensions in /includes/DefaultSettings.php (which should never be edited). To allow additional extensions override $wgFileExtensions in LocalSettings.php.

There are also $wgMimeTypeBlacklist and $wgFileBlacklist for file extensions and MIME types that are never allowed for security reasons, even if added to $wgFileExtensions. If needed for special purposes and considered safe, they can be commented out in these blacklists in LocalSettings.php.

If there is still the error message "The file is corrupt or has an incorrect extension. Please check the file and upload again", the reason can be that the file you want to upload has a MIME type for which only certain file extensions are allowed in /includes/mime.types and has an extension not listed there. If considered safe, the extension can be added in that file. The mime type can be determined with the command file -i filename. Note: Files that are changed manually are then excluded from svn update. To drop own changes and get back to the svn version delete the file and then run svn update (see above).

Logging/Debugging

For debugging, you may enable logging of debug and error messages:

# create a log-file somewhere
  sudo touch /var/www/v-k2n/w/log.txt
  sudo chmod 777 /var/www/v-k2n/w/log.txt
# edit LocalSettings.php and add the following line after the line including the DefaultSettings.php:
  $wgDebugLogFile = "/var/www/v-k2n/w/log.txt";

Note, that the logfile will grow fast, so one should switch on the logging only for short periods of time, and delete the logfile after done.

Backup/Restore in general

Backing up the database alone is documented here: http://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki. A more complete script can be found here: http://www.mediawiki.org/wiki/User:Flominator/Backup_MW - this also backups the folder with uploads (media). Based on that source, adapted scripts were created, execute as:

 cd /var/backups/scripts/; ./backup-mw.sh

The additional backup-mw.php script can potentially be used within www to directly create and download a copy of the mediawiki. We are considering this as a measure to build trust.

In addition, to create an xml dump, make sure a link to AdminSettings.php exists in the current wiki folder and the maintenance folder is temporarily copied, then run, e.g.:

 cd /var/www/v-k2n/w/maintenance # replace path with actual wiki path
 php dumpBackup.php --full > /var/backups/wikis/k2n-full.xml
 php dumpBackup.php --logs > /var/backups/wikis/k2n-logs.xml
 # --logs may not yet be working under version 1.12, it works in 1.14

To restore such a xml-dump, remove tables and create new tables with default values in mysql, then:

 cd /var/www/WIKINAME;  # (replace path with actual wiki path!)
 php ./maintenance/importDump.php /var/backups/wikis/k2n-full.xml --conf ./LocalSettings.php
 php ./maintenance/rebuildrecentchanges.php --conf ./LocalSettings.php    # absolutely necessary
 ## If backlinks etc. do not work, or extensions had to be disabled, use (Very slow!!!!):
 php ./maintenance/rebuildall.php  --quick --conf ./LocalSettings.php

Notes: In our experience, some extensions may create problems during reimport. We found GoogleMaps and DynamicPageList to cause importDump to abort. After disabling these two extensions, the import worked correctly. However, all DPL pages are then still cached without proper DPL rendering even after re-enabling both extensions. Running rebuildall.php fixed this.

Example restore for testing of the wikimediafoundation commons xml-dump:

 cd /var/www/wmf-commons; php ./maintenance/importDump.php  /mnt/wpTest/commonswiki-pages-articles.xml  --conf ./LocalSettings.php



See also: Mediawiki installation