Migrate Dokuwiki data to MediaWiki import data
This is a command line tool to convert the contents of a Dokuwiki into a MediaWiki import data format.
Prerequisites
- PHP >= 8.2 with the
xmlextension must be installed pandoc>= 3.1.6. Thepandoctool must be installed and available in thePATH(https://pandoc.org/installing.html).
Installation
- Download
migrate-dokuwiki.pharfrom https://github.com/hallowelt/migrate-dokuwiki/releases/latest/download/migrate-dokuwiki.phar - Make sure the file is executable. E.g. by running
chmod +x migrate-dokuwiki.phar - Move
migrate-dokuwiki.pharto/usr/local/bin/migrate-dokuwiki(or somewhere else in thePATH)
Workflow
Prepare migration
- Create a directory for the migration source (e.g.
/tmp/migration/input/). - Create a working directory for the migration (e.g.
/tmp/migration/workspace/). - Copy the dokuwiki
datadirectory from dokuwiki to/tmp/migration/workspace/input. - Remove unused directories before copying. Only
attic,media,media-attic,media-meta,meta,pages, can be used for migration.atticandmedia-atticcontain older versions and are not required for migration. - If attic versions should be migrated all archived versions have to be extracted (e.g.
find . -name "*.gz" -exec gunzip {} \;on linux systems).
Migrate the contents
From the parent directory (e.g. /tmp/migration/ ) run the migration commands
1. Run migrate-dokuwiki analyze --src input/ --dest workspace/ to create "working files". After the script has run you can check those files and maybe apply changes if required (e.g. when applying structural changes).
2. Run migrate-dokuwiki extract --src input/ --dest workspace/ to extract all contents, like wikipage contents, attachments and images into the workspace
3. Run migrate-dokuwiki convert --src workspace/ --dest workspace/ (yes, --src workspace/ ) to convert the wikipage contents from Confluence Storage XML to MediaWiki WikiText
4. Run migrate-dokuwiki compose --src workspace/ --dest workspace/ (yes, --src workspace/ ) to create importable data
If you re-run the scripts you will need to clean up the "workspace" directory!
Import into MediaWiki
- Copy the diretory "workspace/result" directory (e.g.
/tmp/migration/workspace/result/) to your target wiki server (e.g./tmp/result) - Go to your MediaWiki installation directory
- Make sure you have the target namespaces set up properly. See
workspace/namespaces-map.phpfor reference. - Make sure $wgFileExtensions is setup properly. See
workspace/result/imagesfor reference. - Move the
workspace/resultdirectory to your MediaWiki server (e.g./tmp). - Use
php maintenance/importImages.php /tmp/result/images/to first import all attachment files and images - Use
php maintenance/importDump.php /tmp/result/output.xmlto import the actual pages
You may need to update your MediaWiki search index afterwards.