Localisation updates from http://translatewiki.net.
[mediawiki.git] / maintenance / dumpBackup.php
blob8c35023a03fe20277ca7c4b4259766e6eabc3131
1 <?php
2 /**
3 * Script that dumps wiki pages or logging database into an XML interchange
4 * wrapper format for export or backup
6 * Copyright © 2005 Brion Vibber <brion@pobox.com>
7 * http://www.mediawiki.org/
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
24 * @file
25 * @ingroup Dump Maintenance
28 $originalDir = getcwd();
30 $optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend' );
32 require_once( __DIR__ . '/commandLine.inc' );
33 require_once( __DIR__ . '/backup.inc' );
35 $dumper = new BackupDumper( $argv );
37 if ( isset( $options['quiet'] ) ) {
38 $dumper->reporting = false;
41 if ( isset( $options['pagelist'] ) ) {
42 $olddir = getcwd();
43 chdir( $originalDir );
44 $pages = file( $options['pagelist'] );
45 chdir( $olddir );
46 if ( $pages === false ) {
47 echo( "Unable to open file {$options['pagelist']}\n" );
48 die(1);
50 $pages = array_map( 'trim', $pages );
51 $dumper->pages = array_filter( $pages, create_function( '$x', 'return $x !== "";' ) );
54 if ( isset( $options['start'] ) ) {
55 $dumper->startId = intval( $options['start'] );
57 if ( isset( $options['end'] ) ) {
58 $dumper->endId = intval( $options['end'] );
61 if ( isset( $options['revstart'] ) ) {
62 $dumper->revStartId = intval( $options['revstart'] );
64 if ( isset( $options['revend'] ) ) {
65 $dumper->revEndId = intval( $options['revend'] );
67 $dumper->skipHeader = isset( $options['skip-header'] );
68 $dumper->skipFooter = isset( $options['skip-footer'] );
69 $dumper->dumpUploads = isset( $options['uploads'] );
70 $dumper->dumpUploadFileContents = isset( $options['include-files'] );
72 $textMode = isset( $options['stub'] ) ? WikiExporter::STUB : WikiExporter::TEXT;
74 if ( isset( $options['full'] ) ) {
75 $dumper->dump( WikiExporter::FULL, $textMode );
76 } elseif ( isset( $options['current'] ) ) {
77 $dumper->dump( WikiExporter::CURRENT, $textMode );
78 } elseif ( isset( $options['stable'] ) ) {
79 $dumper->dump( WikiExporter::STABLE, $textMode );
80 } elseif ( isset( $options['logs'] ) ) {
81 $dumper->dump( WikiExporter::LOGS );
82 } elseif ( isset($options['revrange'] ) ) {
83 $dumper->dump( WikiExporter::RANGE, $textMode );
84 } else {
85 $dumper->progress( <<<ENDS
86 This script dumps the wiki page or logging database into an
87 XML interchange wrapper format for export or backup.
89 XML output is sent to stdout; progress reports are sent to stderr.
91 WARNING: this is not a full database dump! It is merely for public export
92 of your wiki. For full backup, see our online help at:
93 https://www.mediawiki.org/wiki/Backup
95 Usage: php dumpBackup.php <action> [<options>]
96 Actions:
97 --full Dump all revisions of every page.
98 --current Dump only the latest revision of every page.
99 --logs Dump all log events.
100 --stable Stable versions of pages?
101 --pagelist=<file>
102 Where <file> is a list of page titles to be dumped
103 --revrange Dump specified range of revisions, requires
104 revstart and revend options.
105 Options:
106 --quiet Don't dump status reports to stderr.
107 --report=n Report position and speed after every n pages processed.
108 (Default: 100)
109 --server=h Force reading from MySQL server h
110 --start=n Start from page_id or log_id n
111 --end=n Stop before page_id or log_id n (exclusive)
112 --revstart=n Start from rev_id n
113 --revend=n Stop before rev_id n (exclusive)
114 --skip-header Don't output the <mediawiki> header
115 --skip-footer Don't output the </mediawiki> footer
116 --stub Don't perform old_text lookups; for 2-pass dump
117 --uploads Include upload records without files
118 --include-files Include files within the XML stream
119 --conf=<file> Use the specified configuration file (LocalSettings.php)
121 --wiki=<wiki> Only back up the specified <wiki>
123 Fancy stuff: (Works? Add examples please.)
124 --plugin=<class>[:<file>] Load a dump plugin class
125 --output=<type>:<file> Begin a filtered output stream;
126 <type>s: file, gzip, bzip2, 7zip
127 --filter=<type>[:<options>] Add a filter on an output branch
129 ENDS