19require_once __DIR__ .
'/includes/BackupDumper.php';
24 parent::__construct();
27This script dumps the wiki page or logging database into an
28XML interchange wrapper format
for export or backup.
32WARNING:
this is not a full database
dump! It is merely
for public export
33 of your wiki. For full backup, see our online help at:
39 $this->
addOption(
'full',
'Dump all revisions of every page' );
40 $this->
addOption(
'current',
'Dump only the latest revision of every page.' );
41 $this->
addOption(
'logs',
'Dump all log events' );
42 $this->
addOption(
'stable',
'Dump stable versions of pages' );
43 $this->
addOption(
'revrange',
'Dump range of revisions specified by revstart and ' .
44 'revend parameters' );
45 $this->
addOption(
'orderrevs',
'Dump revisions in ascending revision order ' .
46 '(implies dump of a range of pages)' );
48 'Dump only pages included in the file',
false,
true );
50 $this->
addOption(
'start',
'Start from page_id or log_id',
false,
true );
51 $this->
addOption(
'end',
'Stop before page_id or log_id n (exclusive)',
false,
true );
52 $this->
addOption(
'revstart',
'Start from rev_id',
false,
true );
53 $this->
addOption(
'revend',
'Stop before rev_id n (exclusive)',
false,
true );
54 $this->
addOption(
'skip-header',
'Don\'t output the <mediawiki> header' );
55 $this->
addOption(
'skip-footer',
'Don\'t output the </mediawiki> footer' );
56 $this->
addOption(
'stub',
'Don\'t perform old_text lookups; for 2-pass dump' );
57 $this->
addOption(
'uploads',
'Include upload records without files' );
58 $this->
addOption(
'include-files',
'Include files within the XML stream' );
59 $this->
addOption(
'namespaces',
'Limit to this comma-separated list of namespace numbers' );
70 $textMode = $this->
hasOption(
'stub' ) ? WikiExporter::STUB : WikiExporter::TEXT;
73 $this->
dump( WikiExporter::FULL, $textMode );
74 } elseif ( $this->
hasOption(
'current' ) ) {
75 $this->
dump( WikiExporter::CURRENT, $textMode );
76 } elseif ( $this->
hasOption(
'stable' ) ) {
77 $this->
dump( WikiExporter::STABLE, $textMode );
79 $this->
dump( WikiExporter::LOGS );
80 } elseif ( $this->
hasOption(
'revrange' ) ) {
81 $this->
dump( WikiExporter::RANGE, $textMode );
83 $this->
fatalError(
'No valid action specified.' );
88 parent::processOptions();
91 $this->reporting = !$this->
hasOption(
'quiet' );
94 $filename = $this->
getOption(
'pagelist' );
95 $pages = file( $filename );
97 $this->
fatalError(
"Unable to open file {$filename}\n" );
100 $this->pages = array_filter(
$pages,
static function ( $x ) {
106 $this->startId = intval( $this->
getOption(
'start' ) );
110 $this->endId = intval( $this->
getOption(
'end' ) );
114 $this->revStartId = intval( $this->
getOption(
'revstart' ) );
118 $this->revEndId = intval( $this->
getOption(
'revend' ) );
121 $this->skipHeader = $this->
hasOption(
'skip-header' );
122 $this->skipFooter = $this->
hasOption(
'skip-footer' );
123 $this->dumpUploads = $this->
hasOption(
'uploads' );
124 $this->dumpUploadFileContents = $this->
hasOption(
'include-files' );
125 $this->orderRevs = $this->
hasOption(
'orderrevs' );
126 if ( $this->
hasOption(
'namespaces' ) ) {
127 $this->limitNamespaces = explode(
',', $this->
getOption(
'namespaces' ) );
129 $this->limitNamespaces =
null;
136require_once RUN_MAINTENANCE_IF_MAIN;
execute()
Do the actual work.
processOptions()
Processes arguments and sets $this->$sink accordingly.
__construct(?array $args=null)
dump( $history, $text=WikiExporter::TEXT)
string[] null $pages
null means all pages
output( $out, $channel=null)
Throw some output to the user.
loadWithArgv( $argv)
Load params and arguments from a given array of command-line arguments.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
hasOption( $name)
Checks to see if a particular option was set.
getOption( $name, $default=null)
Get an option, or return the default.
addDescription( $text)
Set the description text.