* Add cache-safe alternate sitenotice for anonymous users. (MediaWiki:Anonnotice
[mediawiki.git] / maintenance / dumpBackup.php
blob6f90fc5d1183e8117daf257a4fe44cfe02299835
1 <?php
2 /**
3 * Copyright (C) 2005 Brion Vibber <brion@pobox.com>
4 * http://www.mediawiki.org/
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.
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.
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
21 * @package MediaWiki
22 * @subpackage SpecialPage
25 $originalDir = getcwd();
27 $optionsWithArgs = array( 'server', 'pagelist', 'start', 'end' );
29 require_once( 'commandLine.inc' );
30 require_once( 'SpecialExport.php' );
31 require_once( 'maintenance/backup.inc' );
33 $dumper = new BackupDumper( $argv );
35 if( isset( $options['quiet'] ) ) {
36 $dumper->reporting = false;
38 if( isset( $options['report'] ) ) {
39 $dumper->reportingInterval = intval( $options['report'] );
41 if( isset( $options['server'] ) ) {
42 $dumper->server = $options['server'];
45 if ( isset( $options['pagelist'] ) ) {
46 $olddir = getcwd();
47 chdir( $originalDir );
48 $pages = file( $options['pagelist'] );
49 chdir( $olddir );
50 if ( $pages === false ) {
51 wfDie( "Unable to open file {$options['pagelist']}\n" );
53 $pages = array_map( 'trim', $pages );
54 $dumper->pages = array_filter( $pages, create_function( '$x', 'return $x !== "";' ) );
57 if( isset( $options['start'] ) ) {
58 $dumper->startId = intval( $options['start'] );
60 if( isset( $options['end'] ) ) {
61 $dumper->endId = intval( $options['end'] );
63 $dumper->skipHeader = isset( $options['skip-header'] );
64 $dumper->skipFooter = isset( $options['skip-footer'] );
66 $textMode = isset( $options['stub'] ) ? MW_EXPORT_STUB : MW_EXPORT_TEXT;
68 if( isset( $options['full'] ) ) {
69 $dumper->dump( MW_EXPORT_FULL, $textMode );
70 } elseif( isset( $options['current'] ) ) {
71 $dumper->dump( MW_EXPORT_CURRENT, $textMode );
72 } else {
73 $dumper->progress( <<<END
74 This script dumps the wiki page database into an XML interchange wrapper
75 format for export or backup.
77 XML output is sent to stdout; progress reports are sent to stderr.
79 Usage: php dumpBackup.php <action> [<options>]
80 Actions:
81 --full Dump complete history of every page.
82 --current Includes only the latest revision of each page.
84 Options:
85 --quiet Don't dump status reports to stderr.
86 --report=n Report position and speed after every n pages processed.
87 (Default: 100)
88 --server=h Force reading from MySQL server h
89 --start=n Start from page_id n
90 --end=n Stop before page_id n (exclusive)
91 --skip-header Don't output the <mediawiki> header
92 --skip-footer Don't output the </mediawiki> footer
93 --stub Don't perform old_text lookups; for 2-pass dump
95 Fancy stuff:
96 --plugin=<class>[:<file>] Load a dump plugin class
97 --output=<type>:<file> Begin a filtered output stream;
98 <type>s: file, gzip, bzip2, 7zip
99 --filter=<type>[:<options>] Add a filter on an output branch