Jump to content

Manual:dumpBackup.php

From mediawiki.org
This page is a translated version of the page Manual:DumpBackup.php and the translation is 82% complete.
Outdated translations are marked like this.

詳細

dumpBackup.phpはエキスポートもしくはバックアップのために XMLファイルを作成します。XMLダンプはwikiコンテンツ (各ページのすべての版) を含みますが、サイト関連データは含みません。 DumpBack.php はウィキ データベースのフルバックアップは行わず、利用者アカウント、アップロードファイル、編集記録、削除された版などは含まれません。[1] ダンプを作成した後、XMLをインポートできます。

一般的な例

ダンプファイルの名前を決める必要があります。

For example, with this command, you are saving the revision history of all pages (--full) into a file named dump.xml:

php dumpBackup.php --full > pagedump.xml

You can also include the uploaded files by doing:

php dumpBackup.php --full --include-files --uploads > pageandfiledump.xml
例として使用しているdump.xmlの詳細は下の詳細な例を参照してください。

データダンプは 名前空間 ひとつに制限可能です。最新の版のテンプレートのみの場合:

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

すべての版のテンプレートの場合 :

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

複数の名前空間を含めるには :

php dumpBackup.php --current --quiet --filter=namespace:10,11 > templates_plus_template_talk.xml

プラグインの使用例:

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

または

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

The --stub option can be used with dumpTextPass.php .

To --include-files:

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

--uploadsオプションも使用する必要があります。そうでないと、ファイルが含まれません。

詳細な例

この例で、緑色の文字が入力した文字です

  1. cdコマンドを使用してmaintenanceフォルダに移動します。maintenanceフォルダはご使用の環境により変化します。
  2. php dumpBackup.php --full > /var/tmp/dump.xml と入力して、Enterキーを押します。次のような長いリストが表示されます。

user@server:/$ cd /var/www/html/wiki/w/maintenance

user@server:/var/www/html/wiki/w/maintenance$ php dumpBackup.php --full > /var/tmp/dump.xml

2014-08-15 09:54:08: my_wiki-finddcjobs (ID 23578) 0 pages (0.0|0.0/sec all|curr), 100 revs (404.7|404.7/sec all|curr), ETA 2014-08-15 09:54:11 [max 1143]

2014-08-15 09:54:08: my_wiki-finddcjobs (ID 23578) 0 pages (0.0|0.0/sec all|curr), 200 revs (499.7|652.8/sec all|curr), ETA 2014-08-15 09:54:10 [max 1143]

2014-08-15 09:54:08: my_wiki-finddcjobs (ID 23578) 10 pages (19.2|83.8/sec all|curr), 300 revs (577.4|838.3/sec all|curr), ETA 2014-08-15 09:54:10 [max 1143]

2014-08-15 09:54:08: my_wiki-finddcjobs (ID 23578) 17 pages (24.1|91.4/sec all|curr), 400 revs (567.0|537.9/sec all|curr), ETA 2014-08-15 09:54:10 [max 1143]

2014-08-15 09:54:09: my_wiki-finddcjobs (ID 23578) 18 pages (15.6|40.2/sec all|curr), 500 revs (433.4|223.1/sec all|curr), ETA 2014-08-15 09:54:10 [max 1143]

2014-08-15 09:54:09: my_wiki-finddcjobs (ID 23578) 23 pages (15.4|66.8/sec all|curr), 600 revs (400.6|290.5/sec all|curr), ETA 2014-08-15 09:54:11 [max 1143]

2014-08-15 09:54:09: my_wiki-finddcjobs (ID 23578) 59 pages (36.0|412.4/sec all|curr), 700 revs (426.6|699.0/sec all|curr), ETA 2014-08-15 09:54:10 [max 1143]

2014-08-15 09:54:09: my_wiki-finddcjobs (ID 23578) 62 pages (36.2|856.3/sec all|curr), 800 revs (466.9|1381.2/sec all|curr), ETA 2014-08-15 09:54:10 [max 1143]

2014-08-15 09:54:10: my_wiki-finddcjobs (ID 23578) 89 pages (48.8|798.3/sec all|curr), 900 revs (493.2|896.9/sec all|curr), ETA 2014-08-15 09:54:10 [max 1143]

2014-08-15 09:54:10: my_wiki-finddcjobs (ID 23578) 120 pages (62.4|1224.2/sec all|curr), 1000 revs (520.1|1020.2/sec all|curr), ETA 2014-08-15 09:54:10 [max 1143]

2014-08-15 09:54:10: my_wiki-finddcjobs (ID 23578) 124 pages (59.0|697.5/sec all|curr), 1100 revs (523.7|562.5/sec all|curr), ETA 2014-08-15 09:54:10 [max 1143]

user@server:/var/www/html/wiki/w/maintenance$

新しいxmlファイルがmaintenanceフォルダに作成されます (xmlファイルを表示するにはSCPを更新する必要がある場合があります) 。

オプション

As of MediaWiki 1.39:

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.

WARNING: this is not a full database dump! It is merely for public export of your wiki. For full backup, see our online help at: https://www.mediawiki.org/wiki/Backup

Usage: php dumpBackup.php [--7ziplevel|--conf|--current|--dbgroupdefault|--dbpass|--dbuser|--end|--filter|--full|--globals|--help|--include-files|--logs|--memory-limit|--namespaces|--orderrevs|--output|--pagelist|--plugin|--profiler|--quiet|--report|--revend|--revrange|--revstart|--schema-version|--server|--skip-footer|--skip-header|--stable|--start|--stub|--uploads|--wiki]

Generic maintenance parameters:
    --help (-h): Display this help message
    --quiet (-q): Whether to suppress non-error output

Script dependent parameters:
    --dbgroupdefault: The default DB group to use.
    --dbpass: The password to use for this script
    --dbuser: The DB user to use for this script

Script specific parameters:
    --7ziplevel: 7zip compression level for all 7zip outputs. Used for -mx option to 7za command.
    --conf: Location of LocalSettings.php, if not default
    --current: Dump only the latest revision of every page.
    --end: Stop before page_id or log_id n (exclusive)
    --filter: Add a filter on an output branch. Specify as <type>[:<options>]. <types>s: latest, notalk, namespace
    --full: Dump all revisions of every page
    --globals: Output globals at the end of processing for debugging
    --include-files: Include files within the XML stream
    --logs: Dump all log events
    --memory-limit: Set a specific memory limit for the script, "max" for no limit or "default" to avoid changing it
    --namespaces: Limit to this comma-separated list of namespace numbers
    --orderrevs: Dump revisions in ascending revision order (implies dump of a range of pages)
    --output (-o): Begin a filtered output stream; Specify as <type>:<file>. <type>s: file, gzip, bzip2, 7zip, dbzip2, lbzip2
    --pagelist: Dump only pages included in the file
    --plugin: Load a dump plugin class. Specify as <class>[:<file>].
    --profiler: Profiler output format (usually "text")
    --report: Report position and speed after every n pages processed. Default: 100.
    --revend: Stop before rev_id n (exclusive)
    --revrange: Dump range of revisions specified by revstart and revend parameters
    --revstart: Start from rev_id
    --schema-version: Schema version to use for output. Default: 0.11
    --server: The protocol and server name to use in URLs, e.g. https://en.wikipedia.org. This is sometimes necessary because server name detection may fail in command line scripts.
    --skip-footer: Don't output the </mediawiki> footer
    --skip-header: Don't output the <mediawiki> header
    --stable: Dump stable versions of pages
    --start: Start from page_id or log_id
    --stub: Don't perform old_text lookups; for 2-pass dump
    --uploads: Include upload records without files
    --wiki: For specifying the wiki ID

このスクリプトは通常LocalSettings.php で設定された$wgDBadminuser $wgDBadminpassword を使用してデータベースに接続します。 通常$wgDBadminuserは$wgDBuser より強い権限を持つユーザーですが、dumpBackup.phpを実行するために追加の権限は必要ないため、ユーザー名とパスワードは同じ場合があります。 もし変数が設定されていない場合、dumpBackup.phpはデータベースへの接続に失敗します。

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

注記

XMLファイルは標準出力(stdout)に出力され、進捗状況は標準エラー出力(stderr)に出力されます。 これらは既定の出力とエラー出力です。 このスクリプトをシェルから呼び出すと、両方の出力は既定通りシェルに送信され、"データ"の出力とエラーが画面に表示されます。

エラー メッセージ

もしカレントディレクトリが間違っている場合は、次のメッセージが表示されます。

No input file specified.

"--report"の後ろの変数が0もしくは数字でない場合、"Warning: Division by zero in [DIRECTORY]/maintenance/backup.inc"と表示されます。 解決策として、"--report"オプションなしでdumpBackupを実行します。その場合、100ページごとに進捗状況が出力されます。

推奨される環境設定

  • すべての版がオブジェクトキャッシュに挿入されないように、$wgRevisionCacheExpiry を 0 に設定する必要があります。 wikiの読者は通常、ランダムに古い版を読むことはないので、それらがキャッシュに保存される必要性は低いです。

関連項目

脚注

  1. DumpBackup.php creates an XML interchange wrapper.