Manual:dumpBackup.php

From MediaWiki.org

Jump to: navigation, search
MediaWiki File: dumpBackup.php
Location: /maintenance/
Source code: HEAD

1.15.11.14.11.6.12

Classes: None


dumpBackup.php 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.

This is not a full backup of the wiki database, as it does not include users, passwords, etc.

From the source code (from 1.11.1):

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

This script connects to the database using the username and password defined by $wgDBadminuser and $wgDBadminpassword, which are normally set in AdminSettings.php. The file AdminSettings.php can be created manually from AdminSettings.sample, and is not installed by default. Usually $wgDBadminuser is a user with more privileges than the one in $wgDBuser (set in LocalSettings.php), but for running dumpBackup.php no extra privileges are required, so the usernames and passwords may be the same. If the variables are not set, dumpBackup.php will fail when trying to connect to the database:

$ php dumpBackup.php --full
DB connection error: Unknown error

To get the output of the script in to a file, it's required to forward the output into a file. For example under windows:

php dumpBackup.php --full >d:\backup\dump.xml

To restrict output by namespace, try:

php dumpBackup.php --filter=namespace:10 > templates.xml

Example usage of a plugin:

php dumpBackup.php \
  --plugin=AbstractFilter:extensions/ActiveAbstract/AbstractFilter.php \
  --current \
  --output=gzip:/dumps/abstract.xml.gz \
  --filter=namespace:NS_MAIN \
  --filter=noredirect \
  --filter=abstract

When using the --stub option, the output can be further processed with dumpTextPass.php.

[edit] See also

Manual:Backing up a wiki