MediaWiki
REL1_22
|
00001 <?php 00028 $originalDir = getcwd(); 00029 00030 $optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend' ); 00031 00032 require_once __DIR__ . '/commandLine.inc'; 00033 require_once __DIR__ . '/backup.inc'; 00034 00035 $dumper = new BackupDumper( $argv ); 00036 00037 if ( isset( $options['quiet'] ) ) { 00038 $dumper->reporting = false; 00039 } 00040 00041 if ( isset( $options['pagelist'] ) ) { 00042 $olddir = getcwd(); 00043 chdir( $originalDir ); 00044 $pages = file( $options['pagelist'] ); 00045 chdir( $olddir ); 00046 if ( $pages === false ) { 00047 echo "Unable to open file {$options['pagelist']}\n"; 00048 die( 1 ); 00049 } 00050 $pages = array_map( 'trim', $pages ); 00051 $dumper->pages = array_filter( $pages, create_function( '$x', 'return $x !== "";' ) ); 00052 } 00053 00054 if ( isset( $options['start'] ) ) { 00055 $dumper->startId = intval( $options['start'] ); 00056 } 00057 if ( isset( $options['end'] ) ) { 00058 $dumper->endId = intval( $options['end'] ); 00059 } 00060 00061 if ( isset( $options['revstart'] ) ) { 00062 $dumper->revStartId = intval( $options['revstart'] ); 00063 } 00064 if ( isset( $options['revend'] ) ) { 00065 $dumper->revEndId = intval( $options['revend'] ); 00066 } 00067 $dumper->skipHeader = isset( $options['skip-header'] ); 00068 $dumper->skipFooter = isset( $options['skip-footer'] ); 00069 $dumper->dumpUploads = isset( $options['uploads'] ); 00070 $dumper->dumpUploadFileContents = isset( $options['include-files'] ); 00071 00072 $textMode = isset( $options['stub'] ) ? WikiExporter::STUB : WikiExporter::TEXT; 00073 00074 if ( isset( $options['full'] ) ) { 00075 $dumper->dump( WikiExporter::FULL, $textMode ); 00076 } elseif ( isset( $options['current'] ) ) { 00077 $dumper->dump( WikiExporter::CURRENT, $textMode ); 00078 } elseif ( isset( $options['stable'] ) ) { 00079 $dumper->dump( WikiExporter::STABLE, $textMode ); 00080 } elseif ( isset( $options['logs'] ) ) { 00081 $dumper->dump( WikiExporter::LOGS ); 00082 } elseif ( isset( $options['revrange'] ) ) { 00083 $dumper->dump( WikiExporter::RANGE, $textMode ); 00084 } else { 00085 $dumper->progress( <<<ENDS 00086 This script dumps the wiki page or logging database into an 00087 XML interchange wrapper format for export or backup. 00088 00089 XML output is sent to stdout; progress reports are sent to stderr. 00090 00091 WARNING: this is not a full database dump! It is merely for public export 00092 of your wiki. For full backup, see our online help at: 00093 https://www.mediawiki.org/wiki/Backup 00094 00095 Usage: php dumpBackup.php <action> [<options>] 00096 Actions: 00097 --full Dump all revisions of every page. 00098 --current Dump only the latest revision of every page. 00099 --logs Dump all log events. 00100 --stable Stable versions of pages? 00101 --pagelist=<file> 00102 Where <file> is a list of page titles to be dumped 00103 --revrange Dump specified range of revisions, requires 00104 revstart and revend options. 00105 Options: 00106 --quiet Don't dump status reports to stderr. 00107 --report=n Report position and speed after every n pages processed. 00108 (Default: 100) 00109 --server=h Force reading from MySQL server h 00110 --start=n Start from page_id or log_id n 00111 --end=n Stop before page_id or log_id n (exclusive) 00112 --revstart=n Start from rev_id n 00113 --revend=n Stop before rev_id n (exclusive) 00114 --skip-header Don't output the <mediawiki> header 00115 --skip-footer Don't output the </mediawiki> footer 00116 --stub Don't perform old_text lookups; for 2-pass dump 00117 --uploads Include upload records without files 00118 --include-files Include files within the XML stream 00119 --conf=<file> Use the specified configuration file (LocalSettings.php) 00120 00121 --wiki=<wiki> Only back up the specified <wiki> 00122 00123 Fancy stuff: (Works? Add examples please.) 00124 --plugin=<class>[:<file>] Load a dump plugin class 00125 --output=<type>:<file> Begin a filtered output stream; 00126 <type>s: file, gzip, bzip2, 7zip 00127 --filter=<type>[:<options>] Add a filter on an output branch 00128 00129 ENDS 00130 ); 00131 }