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  subdirectory of MediaWiki installs.

There are dozens of scripts with varying degrees of general utility and quality. You should carefully read the documentation on a script before using it; if a script isn't documented, take additional care running it.

=

Running the scripts


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

Users who do not access the server directly from its terminal will usually establish a connection through ssh.

For Linux/Unix users this is by using the ssh client in a shell.

For Windows users the use of a ssh client application such as the one introduced below is required.

Required program for Windows users: 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.




 * Step 5: Change the current directory to the maintenance subdirectory. You can type  to see what folder you are currently in. The maintenance folder is in the root mediawiki folder.


 * 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:


 * In Windows, the command is:

Standard command-line options
Almost every PHP script in  supports several standard options:
 * --help
 * Displays help message


 * --conf &lt;path&gt;
 * Location of LocalSettings.php, if not default (at parent directory of the script)


 * --dbuser &lt;username&gt;
 * Database account to use instead of the one specified in LocalSettings.php, not used for scripts that don't require a database connection or when SQLite database backend is used


 * --dbpass &lt;password&gt;
 * Database password to use instead of the one specified in LocalSettings.php, 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 &lt;value&gt;
 * Set memory limit for the script. Accepts ordinary numbers, standard php.ini abbreviations (1024K, 20M, 1G),  for no limit (will be used by default if omitted) and   for no change.


 * --quiet
 * Suppress non-error output


 * --wiki &lt;id&gt;
 * Wiki ID for farms>Special:MyLanguage/Manual:Wiki farm|wiki farms. This may be of the form  or  . LocalSettings.php will be run with the   and   constants defined accordingly.


 * --profiler
 * Profiler output format (usually "text").


 * --mwdebug
 * Enable built-in MediaWiki development settings.

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.

MediaWiki installs that use shared settings (family type)
Sometimes MediaWiki is installed as a family for many languages and settings (LocalSettings.php) are split to common part and language parts (see ) where common part is located outside of /w directory and accessed using relative link ( ).

In this case maintenance scripts will not work when running them in /w/maintenance directory.

Run them from /w directory instead:

No shell access
On many shared hosts, you won't have shell access. The following extensions may be useful to run maintenance scripts via the web:  and .

List of maintenance scripts
Instead of this probably-outdated list,


 * View its generated documentation summary.
 * View its generated documentation summary.

Here is the list of files included in the  subdirectory located at the root of a mw>Special:MyLanguage/MediaWiki|MediaWiki installation. 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.). Be aware that these were created and named on an ad hoc basis so have some usability issues.