Last active
February 23, 2023 18:48
-
-
Save mbr0wn/75b4d4763418a0388ffa7510c3be0604 to your computer and use it in GitHub Desktop.
Exporting wiki from Redmine, importing into MediaWiki
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This method does *not* preserve history. Recollected from memory. | |
1. Make sure you have access to the Redmine MySQL database. This is even easier when using phpmyadmin. | |
2. Open database | |
3. Export a table with page title and content. I forget the exact name of the tables, but it was something like: | |
SELECT a.id, a.title, b.content FROM wiki_contents a, wiki_pages b WHERE a.id = b.id; | |
4. Export that result as whatever. I exported it as YAML. | |
5. If you're lucky, you can load the YAML file. I couldn't, there were special characters that would crash the loader (same for JSON). | |
However, you then write a Python or other script that creates a file per page, with the filename being the page title. | |
If the YAML thing worked, something like | |
Y = yaml.safe_load(...) | |
for page in Y: | |
open(page['title'], 'w').write(page['content']) | |
6. Use pandoc to convert from textile to mediawiki (pandoc -f textile -t mediawiki -o OUTFILE INFILE) | |
7. Copy all the files onto the mediawiki server | |
8. Use importTextFiles.php to load the converted files (something like php importTextFiles.php -s "Import from Redmine" -u <username> *) | |
That's it yo. Use extra sed magic before the import to clear out stuff that pandoc can't handle, like {{toc}} etc. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, Thanks for the documentation.
In case that can help anyone, the final php script is in /usr/share/mediawiki/maintenance in Debians, not in the install dir /var/lib/mediawiki.