]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - maintenance/dumpBackup.php
MediaWiki 1.11.0
[autoinstallsdev/mediawiki.git] / maintenance / dumpBackup.php
1 <?php
2 /**
3  * Copyright (C) 2005 Brion Vibber <brion@pobox.com>
4  * http://www.mediawiki.org/
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  * http://www.gnu.org/copyleft/gpl.html
20  *
21  * @addtogroup SpecialPage
22  */
23
24 $originalDir = getcwd();
25
26 $optionsWithArgs = array( 'pagelist', 'start', 'end' );
27
28 require_once( 'commandLine.inc' );
29 require_once( 'backup.inc' );
30
31 $dumper = new BackupDumper( $argv );
32
33 if( isset( $options['quiet'] ) ) {
34         $dumper->reporting = false;
35 }
36
37 if ( isset( $options['pagelist'] ) ) {
38         $olddir = getcwd();
39         chdir( $originalDir );
40         $pages = file( $options['pagelist'] );
41         chdir( $olddir );
42         if ( $pages === false ) {
43                 wfDie( "Unable to open file {$options['pagelist']}\n" );
44         }
45         $pages = array_map( 'trim', $pages );
46         $dumper->pages = array_filter( $pages, create_function( '$x', 'return $x !== "";' ) );
47 }
48
49 if( isset( $options['start'] ) ) {
50         $dumper->startId = intval( $options['start'] );
51 }
52 if( isset( $options['end'] ) ) {
53         $dumper->endId = intval( $options['end'] );
54 }
55 $dumper->skipHeader = isset( $options['skip-header'] );
56 $dumper->skipFooter = isset( $options['skip-footer'] );
57
58 $textMode = isset( $options['stub'] ) ? WikiExporter::STUB : WikiExporter::TEXT;
59
60 if( isset( $options['full'] ) ) {
61         $dumper->dump( WikiExporter::FULL, $textMode );
62 } elseif( isset( $options['current'] ) ) {
63         $dumper->dump( WikiExporter::CURRENT, $textMode );
64 } else {
65         $dumper->progress( <<<END
66 This script dumps the wiki page database into an XML interchange wrapper
67 format for export or backup.
68
69 XML output is sent to stdout; progress reports are sent to stderr.
70
71 Usage: php dumpBackup.php <action> [<options>]
72 Actions:
73   --full      Dump complete history of every page.
74   --current   Includes only the latest revision of each page.
75
76 Options:
77   --quiet     Don't dump status reports to stderr.
78   --report=n  Report position and speed after every n pages processed.
79               (Default: 100)
80   --server=h  Force reading from MySQL server h
81   --start=n   Start from page_id n
82   --end=n     Stop before page_id n (exclusive)
83   --skip-header Don't output the <mediawiki> header
84   --skip-footer Don't output the </mediawiki> footer
85   --stub      Don't perform old_text lookups; for 2-pass dump
86
87 Fancy stuff:
88   --plugin=<class>[:<file>]   Load a dump plugin class
89   --output=<type>:<file>      Begin a filtered output stream;
90                               <type>s: file, gzip, bzip2, 7zip
91   --filter=<type>[:<options>] Add a filter on an output branch
92
93 END
94 );
95 }
96
97