Manual:dumpBackup.php

From MediaWiki.org
Jump to: navigation, search


dumpBackup.php dumps the wiki page database into an XML interchange wrapper format for export or backup.

The XML output is sent to standard output (stdout); progress reports are sent to standard error (stderr).

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

Options[edit | edit source]

From MediaWiki r105912:

This script dumps the wiki page or logging 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 all revisions of every page.
  --current   Dump only the latest revision of every page.
  --logs      Dump all log events.
  --stable    Stable versions of pages?
  --pagelist=<file>
                          Where <file> is a list of page titles to be dumped
  --revrange  Dump specified range of revisions, requires
              revstart and revend options.
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 or log_id n
  --end=n     Stop before page_id or log_id n (exclusive)
  --revstart=n  Start from rev_id n
  --revend=n    Stop before rev_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
  --uploads   Include upload records without files
  --include-files Include files within the XML stream
  --conf=<file> Use the specified configuration file (LocalSettings.php)

  --wiki=<wiki>  Only back up the specified <wiki>

Fancy stuff: (Works? Add examples please.)
  --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 LocalSettings.php. Although AdminSettings.php is obsolete, it can use the username and password set in that file too. Usually $wgDBadminuser is a user with more privileges than the one in $wgDBuser, 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

Examples[edit | edit source]

To get the output of the script in to a file, it's required to forward the output into a file. For example, to save the output into a file named dump.xml, use:

php dumpBackup.php --full > dump.xml

To restrict output by namespace, try:

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

If you want to include multiple namespaces, try:

php dumpBackup.php --current --filter=namespace:10,11 > templates_plus_template_talk.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

or

php dumpBackup.php \
  --plugin=MathMLFilter:../extensions/MathSearch/maintenance/MathDump.php \
  --current  \
  --filter=namespace:NS_MAIN \
  --filter=mathml

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

Example of usage of --include-files

php dumpBackup.php \
  --full \
  --include-files \
  --uploads \
  --output=gzip:/dumps/abstract.xml.gz

You will need to set the --uploads option too. Otherwise no files will be included.

Error messages[edit | edit source]

If you are not in the correct folder, you will receive this message:

No input file specified.

The dumpBackup script says "Warning: Division by zero in [DIRECTORY]/maintenance/backup.inc" when the parameter after "--report" evaluates as 0 or not-a-number. The fix is to run dumpBackup without the "--report" option; then dumpBackup will print a status line every 100 pages processed.

See also[edit | edit source]