Help:Maintenance scripts overview

From ENWiki

Jump to: navigation, search

MediaWiki includes a range of maintenance scripts in the maintenance/ directory of the installation. These scripts are designed to be run from the command line on the server. To run the php scripts (eg refreshLinks.php , rebuildall.php), use the following syntax at a command prompt on your wiki server:

foo@bar:~/www/mediawiki/maintenance$ php refreshLinks.php

To be able to use these scripts, you have to setup the file AdminSettings.php in the base directory of the installation. This can be done by renaming and editing the file AdminSettings.sample in the same directory.

Remember that MediaWiki is developed mainly for the Wikimedia Foundation projects : it just happens to work for other people. Most maintenance scripts are used by the wiki administrator to do... maintenance. As the maintainers of Wikimedia sites are also developers, most of the time they don't write any documentation.

Contents

1.5rc4

alltrans.php 
Prints a list of allmessages in english, to facilitate translations.
attribute.php 
Has not been updated for 1.5x database schema.
rebuildall.php 
rebuildall is designed to rebuild the database links and indices.
clear_stats.php 
Resets statistics in the Special:Statistics page.
deleteOldRevisions.php 
Removes page histories.
Rebuildall.php
is one of the scripts included in the maintenance/ directory of your MediaWiki installation. Its purpose is to rebuild the links and indices used for searching your site.

warning: In MediaWiki 1.5rc4 Rebuildall.php will empty your recent changes table in the process. You will not be able to discern what has recently been changed on your site.

1.5.8

rebuildMessages.php
refresh the messages in the database from the LanguageXX.php file (from here)

1.6.7

Rebuildall.php
is one of the scripts included in the maintenance/ directory of your MediaWiki installation. Its purpose is to rebuild the links and indices used for searching your site.

1.11.0

Note from the README in the directory: The .sql scripts in this directory are not intended to be run standalone, although this is appropriate in some cases, e.g. manual creation of blank tables prior to an import.

Most of the PHP scripts need to be run from the command line. Prior to doing so, ensure that the LocalSettings.php file in the directory above points to the proper installation.

Certain scripts will require elevated access to the database. In order to provide this, first create a MySQL user with "all" permissions on the wiki database, and then place their username and password in an AdminSettings.php file in the directory above. See AdminSettings.sample for specifics on this.

Brief explanation of files

A lot of the files in this directory are PHP scripts used to perform various maintenance tasks on the wiki database, e.g. rebuilding link tables, updating the search indices, etc. The files in the "archives" directory are used to upgrade the database schema when updating the software. Some schema definitions for alternative (as yet unsupported) database management systems are stored here too.

The "storage" directory contains scripts and resources useful for working with external storage clusters, and are not likely to be particularly useful to the vast majority of installations. This directory does contain the compressOld scripts, however, which can be useful for compacting old data.

Maintenance scripts

As noted above, these should be run from the command line. Not all scripts are listed, as some are Wikimedia-specific, and some are not applicable to most installations.

       changePassword.php
       Reset the password of a specified user
       cleanupSpam.php
       Mass-revert insertion of linkspam
       createAndPromote.php
       Create a user with administrator (and optionally, bureaucrat) permissions
       deleteOldRevisions.php
       Erase old revisions of pages from the database
       dumpBackup.php
       Backup dump script
       dumpHTML.php
       Produce an HTML dump of a wiki
       importDump.php
       XML dump importer
       importImages.php
       Import images into the wiki
       importTextFile.php
       Import the contents of a text file into a wiki page
       nukePage.php
       Wipe a page and all revisions from the database
       reassignEdits.php
       Reassign edits from one user to another
       rebuildImages.php
       Update image metadata records
       rebuildMessages.php
       Update the MediaWiki namespace after changing site language
       rebuildtextindex.php
       Rebuild the fulltext search indices
       refreshLinks.php
       Rebuild the link tables
       removeUnusedAccounts.php
       Remove user accounts which have made no edits
       runJobs.php
       Immediately complete all jobs in the job queue
       update.php
       Check and upgrade the database schema to the current version


addwiki.php
Usage: php addwiki.php <language> <site> <dbname>\n"
attachLatest.php
quick hackjob to fix damages imports on wikisource
attribute.php
Script for re-attributing edits: "Usage: php attribute.php <language> <site> <source> <destination> "
benchmarkPurge.php
Squid purge benchmark script. Squid purge benchmark doesn't do much without squid support on.
build-intl-wiki.sql
Experimental: create shared international database
changePassword.php
Change the password of a given user: Usage: php changePassword.php [--user=user --password=password | --help]


cleanupCaps.php
Script to clean up broken page links when somebody turns on $wgCapitalLinks.: Usage: php cleanupCaps.php [--dry-run] <-- Where --dry-run don't actually try moving them.
cleanupImages.php
Script to clean up broken, unparseable upload filenames.:Usage: php cleanupImages.php [--fix] <-- Where --fix Actually clean up titles; otherwise just checks for them.
cleanupSpam.php
The cleanupSpam takes a url as argument, and find out all the articles which contains the url and remove it. The script can end up deleting valid articles that just have spam added on the end.
cleanupTitles.php
Script to clean up broken, unparseable titles
cleanupWatchlist.php
Script to remove broken, unparseable titles in the Watchlist.
clear_interwiki_cache.php
This script is used to clear the interwiki links for ALL languages in memcache.
clear_stats.php
convertLinks.php
Convert from the old links schema (string->ID) to the new schema (ID->ID).
counter.php
createAndPromote.php
Maintenance script to create an account and grant it administrator rights.
database.sql
SQL script to create database for wiki. This is run from the installation script which replaces the variables with their values from local settings.
deleteArchivedFiles.php
Delete archived (non-current) files from the database.
deleteArchivedRevisions.php
Delete archived (deleted from public) revisions from the database
deleteBatch.php
delete a batch of pages: Usage: php deleteBatch.php [-u <user>] [-r <reason>] [-i <interval>] <listfile>
where
      <listfile> is a file where each line contains the title of a page to be deleted.
      <user> is the username
      <reason> is the delete reason
      <interval> is the number of seconds to sleep for after each delete
deleteDefaultMessages.php
Deletes all pages in the MediaWiki namespace which were last edited by "MediaWiki default".
deleteImageMemcached.php
deleteOldRevisions.php
Delete old (non-current) revisions from the database
deleteOrphanedRevisions.php
Maintenance script to delete revisions which refer to a nonexisting page
deleteRevision.php
Usage: php deleteRevision.php <revid> [<revid> ...]
dumpBackup.php
This script dumps the wiki page database into an XML interchange wrapper format for export or backup.
XML output is sent to stdout; progress reports are sent to stderr.

Usage: php dumpBackup.php <action> [<options>]
Actions:
  --full      Dump complete history of every page.
  --current   Includes only the latest revision of each page.

Options:
  --quiet     Don't dump status reports to stderr.
  --report=n  Report position and speed after every n pages processed.
              (Default: 100)
  --server=h  Force reading from MySQL server h
  --start=n   Start from page_id n
  --end=n     Stop before page_id n (exclusive)
  --skip-header Don't output the <mediawiki> header
  --skip-footer Don't output the </mediawiki> footer
  --stub      Don't perform old_text lookups; for 2-pass dump

Fancy stuff:
  --plugin=<class>[:<file>]   Load a dump plugin class
  --output=<type>:<file>      Begin a filtered output stream;
                              <type>s: file, gzip, bzip2, 7zip
  --filter=<type>[:<options>] Add a filter on an output branch


dumpHTML.php
Usage:
php dumpHTML.php --help
php dumpHTML.php [options...]

        --help               show this message

        -d <dest>            destination directory
        -s <start>           start ID
        -e <end>             end ID
        -k <skin>            skin to use (defaults to htmldump)
        --no-overwrite       skip existing HTML files
        --checkpoint <file>  use a checkpoint file to allow restarting of interrupted du
mps
        --slice <n/m>        split the job into m segments and do the n'th one
        --images             only do image description pages
        --shared-desc        only do shared (commons) image description pages
        --no-shared-desc     don't do shared image description pages
        --categories         only do category pages
        --redirects          only do redirects
        --special            only do miscellaneous stuff
        --force-copy         copy commons instead of symlink, needed for Wikimedia
        --interlang          allow interlanguage links
        --image-snapshot     copy all images used to the destination directory
        --compress           generate compressed version of the html pages
        --udp-profile <N>    profile 1/N rendering operations using ProfilerSimpleUDP
dumpInterwiki.php
Rebuild interwiki table using the file on meta and the language list
dumpLinks.php
dumpSisterSites.php
dumpTextPass.php
This script postprocesses XML dumps from dumpBackup.php to add

page text which was stubbed out (using --stub).

XML input is accepted on stdin.
XML output is sent to stdout; progress reports are sent to stderr.

Usage: php dumpTextPass.php [<options>]
Options:
  --stub=<type>:<file> To load a compressed stub dump instead of stdin
  --prefetch=<type>:<file> Use a prior dump file as a text source, to save
              pressure on the database.
              (Requires PHP 5.0+ and the XMLReader PECL extension)
  --quiet     Don't dump status reports to stderr.
  --report=n  Report position and speed after every n pages processed.
              (Default: 100)
  --server=h  Force reading from MySQL server h
  --current   Base ETA on number of pages in database instead of all revisions
<pre>

;dumpUploads.php: Generates list of uploaded files which can be fed to tar or similar.
By default, outputs relative paths against the parent directory of
\$wgUploadDirectory.
<pre>Usage:
php dumpUploads.php [options] > list-o-files.txt

Options:
--base=<path>  Set base relative path instead of wiki include root

FIXME: other options not implemented yet ;)

--local        List all local files, used or not. No shared files included.
--used         Skip local images that are not used
--shared       Include images used from shared repository


edit.php
Edit an article from the command line
Usage: php edit.php [options...] <title>

Options:
  -u <user>         Username
  -s <summary>      Edit summary
  -m                Minor edit
  -b                Bot (hidden) edit
  -a                Enable autosummary
  --no-rc           Do not show the change in recent changes

If the specified user does not exist, it will be created.
The text for the edit will be read from stdin.
eval.php
fetchInterwiki.pl
findhooks.php
fixSlaveDesync.php
fixTimestamps.php
fixUserRegistration.php
fuzz-tester.php
generateSitemap.php
getLagTimes.php
getSlaveServer.php
importDump.php
importImages.php
importLogs.php
importTextFile.php
importUseModWiki.php
initEditCount.php
initStats.php
installExtension.php
mcc.php
mctest.php
moveBatch.php
mwdocgen.php
namespace2sql.php
namespaceDupes.php
nextJobDB.php
nukeNS.php
nukePage.php
orphans.php
ourusers.php
parserTestsParserHook.php
parserTestsParserTime.php
parserTests.php
parserTestsStaticParserHook.php
purgeList.php
purgeOldText.php
reassignEdits.inc.php
reassignEdits.php
rebuildall.php
rebuildImages.php
rebuildInterwiki.php
rebuildrecentchanges.php
rebuildtextindex.php
refreshImageCount.php
refreshLinks.php
removeUnusedAccounts.php
renamewiki.php
renderDump.php
runJobs.php
showJobs.php
showStats.php
sql.php
stats.php
undelete.php
updateArticleCount.php
update.php
updateRestrictions.php
updateSearchIndex.php
updateSpecialPages.php
upgrade1_5.php
userOptions.php
waitForSlave.php