Help:Maintenance scripts

Maintenance scripts are powerful tools for keeping your wiki in good shape, but they require careful use due to their potential to change data or database structure. Below are are some useful MediaWiki maintenance scripts for wiki administrators.

update.php

  • Purpose: Updates the database schema during upgrades or when extensions are added that require schema changes.
  • Use: Essential after upgrading MediaWiki or installing new extensions that modify the database. It ensures your database is compatible with the new software version or extension requirements.
  • When to Run:
    • After any MediaWiki update.
    • After installing or updating extensions that require database changes.

bash

php maintenance/update.php

refreshLinks.php

  • Purpose: Rebuilds the links table which can fix broken links and update link references.
  • Use: Useful for fixing link-related issues or after importing pages with incorrect links.
  • When to Run:
    • If you've noticed link tracking issues.
    • After a large import of content.

bash

php maintenance/refreshLinks.php

rebuildtextindex.php

  • Purpose: Rebuilds the text search index, which can help improve search functionality or fix search issues.
  • Use: If search functionality is not working as expected or after importing a lot of content.

bash

php maintenance/rebuildtextindex.php

importDump.php

  • Purpose: Imports an XML dump file into your wiki, which can be used for transferring content between wikis or for restoring backups.
  • Use: When moving content from one wiki to another or restoring from a backup.
  • When to Run:
    • When you need to import content from another wiki or restore content.

bash

php maintenance/importDump.php <filename>

deleteBatch.php

  • Purpose: Deletes a list of pages provided in a file or via command line arguments.
  • Use: Useful for removing spam or bulk deleting pages that are no longer needed.
  • When to Run:
    • For cleaning up vandalism or unwanted pages in bulk.

bash

php maintenance/deleteBatch.php -r <reason> <page-list-file>

runJobs.php

  • Purpose: Processes jobs queued by MediaWiki for deferred tasks like email notifications, category membership, or link updates.
  • Use: To ensure all background tasks are executed, especially important in environments with high activity.
  • When to Run:
    • Regularly, can be scheduled via cron or manually when you see pending jobs.

bash

php maintenance/runJobs.php

populateCategory.php

  • Purpose: Fills the categorylinks table with data from pages using the [[Category:...]] syntax that haven't been correctly categorized yet.
  • Use: If categories suddenly appear empty or if there's a need to ensure all pages are correctly categorized.
  • When to Run:
    • After importing pages or if category data seems out of sync.

bash

php maintenance/populateCategory.php

Recommendations

  • Backup Before Running: Always backup your database before executing maintenance scripts that modify or could potentially corrupt data.
  • Test Environment: If possible, test these scripts in a staging or test environment first to understand their impact.
  • Read Documentation: Each script's documentation on MediaWiki.org provides specific usage instructions, options, and potential caveats.
  • Cron Jobs for Regular Maintenance: Scripts like runJobs.php should be set up to run periodically via cron jobs to manage background tasks efficiently.
  • Monitor Performance: Running these scripts, especially on large wikis, can be resource-intensive. Ensure your server can handle the load, and consider running them during off-peak hours.