* Magic Word testcases, not all of them and the namespace stuff is broken (& disabled)
[lhc/web/wiklou.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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @package MediaWiki
22 * @subpackage SpecialPage
23 */
24
25 $originalDir = getcwd();
26
27 $optionsWithArgs = array( 'server', 'pagelist', 'start', 'end' );
28
29 require_once( 'commandLine.inc' );
30 require_once( 'SpecialExport.php' );
31 require_once( 'maintenance/backup.inc' );
32
33 $dumper = new BackupDumper( $argv );
34
35 if( isset( $options['quiet'] ) ) {
36 $dumper->reporting = false;
37 }
38 if( isset( $options['report'] ) ) {
39 $dumper->reportingInterval = intval( $options['report'] );
40 }
41 if( isset( $options['server'] ) ) {
42 $dumper->server = $options['server'];
43 }
44
45 if ( isset( $options['pagelist'] ) ) {
46 $olddir = getcwd();
47 chdir( $originalDir );
48 $pages = file( $options['pagelist'] );
49 chdir( $olddir );
50 if ( $pages === false ) {
51 print "Unable to open file {$options['pagelist']}\n";
52 exit;
53 }
54 $pages = array_map( 'trim', $pages );
55 $dumper->pages = array_filter( $pages, create_function( '$x', 'return $x !== "";' ) );
56 }
57
58 if( isset( $options['start'] ) ) {
59 $dumper->startId = intval( $options['start'] );
60 }
61 if( isset( $options['end'] ) ) {
62 $dumper->endId = intval( $options['end'] );
63 }
64 $dumper->skipHeader = isset( $options['skip-header'] );
65 $dumper->skipFooter = isset( $options['skip-footer'] );
66
67 $textMode = isset( $options['stub'] ) ? MW_EXPORT_STUB : MW_EXPORT_TEXT;
68
69 if( isset( $options['full'] ) ) {
70 $dumper->dump( MW_EXPORT_FULL, $textMode );
71 } elseif( isset( $options['current'] ) ) {
72 $dumper->dump( MW_EXPORT_CURRENT, $textMode );
73 } else {
74 $dumper->progress( <<<END
75 This script dumps the wiki page database into an XML interchange wrapper
76 format for export or backup.
77
78 XML output is sent to stdout; progress reports are sent to stderr.
79
80 Usage: php dumpBackup.php <action> [<options>]
81 Actions:
82 --full Dump complete history of every page.
83 --current Includes only the latest revision of each page.
84
85 Options:
86 --quiet Don't dump status reports to stderr.
87 --report=n Report position and speed after every n pages processed.
88 (Default: 100)
89 --server=h Force reading from MySQL server h
90 --start=n Start from page_id n
91 --end=n Stop before page_id n (exclusive)
92 --skip-header Don't output the <mediawiki> header
93 --skip-footer Don't output the </mediawiki> footer
94 --stub Don't perform old_text lookups; for 2-pass dump
95
96 Fancy stuff:
97 --plugin=<class>[:<file>] Load a dump plugin class
98 --output=<type>:<file> Begin a filtered output stream;
99 <type>s: file, gzip, bzip2, 7zip
100 --filter=<type>[:<options>] Add a filter on an output branch
101
102 END
103 );
104 }
105
106 ?>