Transferring Wikibase data between wikis

Learn how to transfer Wikibase data from one wiki to another.

Transferring items and properties from one wiki to another is not that difficult if you know which steps to take. This post describes a 3 step process using the primary import/export mechanism of MediaWiki. This process retains your item and property IDs and (optionally) your revision history. It also works well between different versions of MediaWiki and Wikibase.

Step 1: create an XML dump

php maintenance/dumpBackup.php --full --quiet --filter=namespace:120,122 > wikibase.xml

This command needs to be run on the command line from the root directory of your wiki. It creates a wikibase.xml file which we will need in step 2.

If you wish to only export items, remove 122 (the property namespace) and the comma. Likewise, you can remove 120 (the item namespace) to only export properties. To export all wiki content, including talk pages, remove --filter=namespace:120,122 from the command. For more information, read the dumpBackup.php documentation.

If you do not have access to the wikis server, you can get an XML dump via Special:Export.

Step 2: import the XML dump

Copy the wikibase.xml file to the root directory of the wiki where you wish to do the import. Then run this command on the command line:

php maintenance/importDump.php < ../wikibase.xml

For large imports, it will take a while for the script to finish. If it completes without an error it outputs “Done!”. Likely you will get the following error instead:

To avoid ID conflicts, the import of Wikibase entities is not supported. You can enable imports using the “allowEntityImport” setting.

This error is expected, as Wikibase by default, and for good reason, does not allow importing items and properties. To temporarily enable such imports, add the following to the end of LocalSettings.php and rerun the importDump.php command. After the command has run, disable imports again by removing the line from LocalSettings.php.

$wgWBRepoSettings['allowEntityImport'] = true;

For more information, read the MediaWiki XML import documentation.

Step 3: run rebuild scripts

Run these commands from the root directory of the wiki where you did the import:

php maintenance/rebuildall.php

php maintenance/runJobs.php

php maintenance/initSiteStats.php --update



Leave a Comment


No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *