MediaWiki
REL1_19
|
00001 <?php 00028 $originalDir = getcwd(); 00029 00030 $optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend'); 00031 00032 require_once( dirname( __FILE__ ) . '/commandLine.inc' ); 00033 require_once( '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 Usage: php dumpBackup.php <action> [<options>] 00092 Actions: 00093 --full Dump all revisions of every page. 00094 --current Dump only the latest revision of every page. 00095 --logs Dump all log events. 00096 --stable Stable versions of pages? 00097 --pagelist=<file> 00098 Where <file> is a list of page titles to be dumped 00099 --revrange Dump specified range of revisions, requires 00100 revstart and revend options. 00101 Options: 00102 --quiet Don't dump status reports to stderr. 00103 --report=n Report position and speed after every n pages processed. 00104 (Default: 100) 00105 --server=h Force reading from MySQL server h 00106 --start=n Start from page_id or log_id n 00107 --end=n Stop before page_id or log_id n (exclusive) 00108 --revstart=n Start from rev_id n 00109 --revend=n Stop before rev_id n (exclusive) 00110 --skip-header Don't output the <mediawiki> header 00111 --skip-footer Don't output the </mediawiki> footer 00112 --stub Don't perform old_text lookups; for 2-pass dump 00113 --uploads Include upload records without files 00114 --include-files Include files within the XML stream 00115 --conf=<file> Use the specified configuration file (LocalSettings.php) 00116 00117 --wiki=<wiki> Only back up the specified <wiki> 00118 00119 Fancy stuff: (Works? Add examples please.) 00120 --plugin=<class>[:<file>] Load a dump plugin class 00121 --output=<type>:<file> Begin a filtered output stream; 00122 <type>s: file, gzip, bzip2, 7zip 00123 --filter=<type>[:<options>] Add a filter on an output branch 00124 00125 ENDS 00126 ); 00127 }