Problem statement: Let’s understand the problem very clearly. We have created wiki pages with attachments such as documents, images, etc and now we want to completely move them to another environment. You might think that direct copy-paste the MD (markdown) code should work. But it copies the format and text-only not the attachments. Try it once. So, how to solve it?
First, let’s understand that wiki is also git repo and it should be easy to clone, pull and push. There are a few caveats which I will bring to your attention and fix them.
We can’t directly transfer them:
As far as I did research there is no direct way to transfer them from one environment to another. So, we will follow the below approach. In case you found a better solution, please share it with us also.
We will complete the process in 7 steps:
Step 1: Make sure you have edit access to both repositories. Create dummy pages/edit/save on both repo and you will verify it.
Step 2: Create 2 separate folders on your local system. Name them such that they are easily identifiable. Say folder 1: ‘Personal repo” and folder 2: “Enterprise repo”
Step 3: We will create a wiki page on personal DevOps with attachment such as file and image. I hope you already have wiki pages with attachments and hence you are here to find a solution. 😊
I have put text, an image, and an attachment (doc) file.
Step 4: Go to Wiki setting and clone it to your local computer using below command. Clone it to your folder 1: “Personal repo”
Step 5: Now repeat steps 3 and 4 on your enterprise environment. There you just create a demo wiki with at least 1 image.
Step 6: Here is the trick. Please follow it very carefully. And every time you want to migrate pages from personal to the enterprise you must do these steps. So, to avoid it, make sure you migrate from personal to the enterprise for once and all.
Step 6.1: Copy and paste the images/attachment from “Personal repo” to “Enterprise repo”. I brought the word document and the image from “Personal repo” to “Enterprise repo”
Step 6.2: Manually copy-paste all wiki pages (not .git files) from personal to enterprise. Note you shouldn’t move the below boxed files. For attachments, we have directly pasted in .attachments folder.
Step 6.3: Update .order file in “Enterprise repo”. Just copy text from “Personal repo”. Also, you must update/bring all order files in case you have sub-pages on “Personal repo”.
Note: During this exercise make sure you don’t move .git files.
Step 7: Finally, you have everything on “Enterprise repo” and now you are ready to push it to git. Run git bash again on your “Enterprise folder” and type the below command.
git add *
# Comment - don't run these lines - you need to manually add all attachments...
# just type .att and press tab and then type Blog and press tab and go on till you add the right file
git add .attachments/Blog\ draft\ -\ Tensorflow-9305a061-c76b-4173-9d66-9c274e860152.docx
git add .attachments/image-b09aae39-1ec4-49ed-874f-5af54b99720f.png
git commit -m "added attachment and update the wiki from personal"
You are done! Open any page on enterprise repo and check if all images and attachments are properly coming up. If you want you can delete the demo page from Enterprise wiki. I hope it fixed your problem. Please don’t forget to share your thoughts and love below. In case you have subpages and need help on Step 6.3, please comment below.