Manual:Maintenance scripts

The maintenance scripts are used to perform various administrative, import, maintenance, reporting and upgrade tasks. The scripts are written in PHP and live in the maintenance subdirectory of MediaWiki installs.

There are dozens of scripts with varying degrees of general utility and quality - because of this, it is best to carefully read the documentation on a script before using it. If a script is not documented, this often indicates that additional care should be taken.

Configuration
The  and   configuration variables must be set in order to run some maintenance scripts. The values for these variables differ based on the database engine that is being used to power your installation of MediaWiki.

MySQL
Some of the maintenance scripts require database permissions that, for security reasons, the main MediaWiki database account should not have. A separate database account with 'superuser' privileges for just the MediaWiki database should be created (if it does not already exist.) For example, if the database that you use for MediaWiki is called , then the following SQL would create such a user who can exercise superuser privileges on localhost.:

Once the account exists, the account name should be set in the  configuration variable. Like other configuration variables,  should be set in LocalSettings.php. A password for  must be set in the   configuration variable.

PostgreSQL
PostgreSQL uses a different security model than MySQL and the same PostgreSQL server account used for day-to-day operation of the MediaWiki installation must also be used for running the maintenance scripts. This is necessary to ensure that the owner for new tables created by the maintenance scripts is set correctly. Simply set  to   and    to.

Running the scripts
The maintenance scripts must then be run from the command line.

Required program: PuTTY or any terminal emulator


 * Step 1: Download and run PuTTY a terminal emulator.
 * Step 2: In PuTTy, under the Host Name (or IP address) enter the IP Address of your web hosting site (Contact your website provider if necessary) and click Open.


 * Step 3: A command screen will pop up. At the login as: line enter the FTP user name.


 * Step 4: Enter the FTP password.

$ cd maintenance
 * Step 5: Change the current directory to the maintenance subdirectory:

$ php rebuildall.php
 * Step 6: Execute the maintenance script that needs to be run:
 * If you get an error (for example: php.exe is no valid Win32 application), try the following:

$ php-cgi rebuildall.php
 * In Windows, the command is;

$ C:\path\to\php\php-win.exe C:\path\to\mediawiki\maintenance\rebuildall.php

Standard command-line options
Almost every PHP script in /maintenance supports several standard options:
 * --help : Displays help message
 * --conf : Location of LocalSettings.php, if not default (at parent directory of the script)
 * --dbuser : Database account to use, not used for scripts that don't require a database connection or when SQLite database backend is used
 * --dbpass : Database password to use, not used for scripts that don't require a database connection or when SQLite database backend is used
 * --globals : Output globals at the end of processing for debugging
 * --memory-limit : Set memory limit for the script. Accepts ordinary numbers, standard php.ini abbreviations (1024K, 20M, 1G), max for no limit (will be used by default if omitted) and default for no change. Available only since MediaWiki 1.17.
 * --quiet : Whether to supress non-error output
 * --wiki : For specifying the wiki ID

MediaWiki installs that use symlinks
In cases where the MediaWiki php files are symlinked to a central installation you will need to specify to the maintenance script the path of the LocalSettings.php file. For example: php maintenance/importImages.php --conf /var/wwwdata/website.org/wiki/LocalSettings.php /tmp/wikiimages .jpg .png .svg Otherwise you will get this error: A copy of your installation's LocalSettings.php must exist and be readable in the source directory.

List of maintenance scripts
Here is the list of files included in the maintenance subdirectory located at the root of a MediaWiki installation. This list was created from the documentation located in the Documentation trunk and may not accurately reflect the contents of the maintenance subdirectory of the current release of the software.

You can contribute to this manual by keeping this list up to date, adding a description of these files' specific purpose and of how an administrator should use them (command line examples, etc.).

/maintenance/archives/
The scripts included in the archive subdirectory have been designed for updating databases from older versions of the software.
 * populateSha1.php
 * rebuildRecentchanges.inc
 * upgradeWatchlist.php

/maintenance/dtrace/

 * counts.d
 * tree.d

/maintenance/language/

 * alltrans.php
 * checkExtensions.php
 * checkLanguage.inc
 * checkLanguage.php
 * date-formats.php
 * diffLanguage.php
 * digit2html.php
 * dumpMessages.php
 * function-list.php
 * lang2po.php
 * langmemusage.php
 * languages.inc
 * messages.inc
 * messageTypes.inc
 * rebuildLanguage.php
 * splitLanguageFiles.inc
 * splitLanguageFiles.php
 * transstat.php
 * validate.php
 * writeMessagesArray.inc

/maintenance/storage/

 * checkStorage.php
 * compressOld.inc
 * compressOld.php
 * dumpRev.php
 * moveToExternal.php
 * resolveStubs.php