ISO 8601 timestamps can have decimal seconds
[mediawiki.git] / maintenance / dumpBackup.php
blobde7ce65529e29b17e2bb291387df08dd30f8bb80
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
21 * @file
22 * @ingroup Dump Maintenance
25 $originalDir = getcwd();
27 $optionsWithArgs = array( 'pagelist', 'start', 'end' );
29 require_once( 'commandLine.inc' );
30 require_once( 'backup.inc' );
32 $dumper = new BackupDumper( $argv );
34 if( isset( $options['quiet'] ) ) {
35 $dumper->reporting = false;
38 if ( isset( $options['pagelist'] ) ) {
39 $olddir = getcwd();
40 chdir( $originalDir );
41 $pages = file( $options['pagelist'] );
42 chdir( $olddir );
43 if ( $pages === false ) {
44 wfDie( "Unable to open file {$options['pagelist']}\n" );
46 $pages = array_map( 'trim', $pages );
47 $dumper->pages = array_filter( $pages, create_function( '$x', 'return $x !== "";' ) );
50 if( isset( $options['start'] ) ) {
51 $dumper->startId = intval( $options['start'] );
53 if( isset( $options['end'] ) ) {
54 $dumper->endId = intval( $options['end'] );
56 $dumper->skipHeader = isset( $options['skip-header'] );
57 $dumper->skipFooter = isset( $options['skip-footer'] );
58 $dumper->dumpUploads = isset( $options['uploads'] );
60 $textMode = isset( $options['stub'] ) ? WikiExporter::STUB : WikiExporter::TEXT;
62 if( isset( $options['full'] ) ) {
63 $dumper->dump( WikiExporter::FULL, $textMode );
64 } elseif( isset( $options['current'] ) ) {
65 $dumper->dump( WikiExporter::CURRENT, $textMode );
66 } elseif( isset( $options['logs'] ) ) {
67 $dumper->dump( WikiExporter::LOGS );
68 } else {
69 $dumper->progress( <<<ENDS
70 This script dumps the wiki page database into an XML interchange wrapper
71 format for export or backup.
73 XML output is sent to stdout; progress reports are sent to stderr.
75 Usage: php dumpBackup.php <action> [<options>]
76 Actions:
77 --full Dump complete history of every page.
78 --current Includes only the latest revision of each page.
79 --logs Dump action logs for every page.
81 Options:
82 --quiet Don't dump status reports to stderr.
83 --report=n Report position and speed after every n pages processed.
84 (Default: 100)
85 --server=h Force reading from MySQL server h
86 --start=n Start from page_id n
87 --end=n Stop before page_id n (exclusive)
88 --skip-header Don't output the <mediawiki> header
89 --skip-footer Don't output the </mediawiki> footer
90 --stub Don't perform old_text lookups; for 2-pass dump
91 --uploads Include upload records (experimental)
93 Fancy stuff:
94 --plugin=<class>[:<file>] Load a dump plugin class
95 --output=<type>:<file> Begin a filtered output stream;
96 <type>s: file, gzip, bzip2, 7zip
97 --filter=<type>[:<options>] Add a filter on an output branch
99 ENDS