How to transfer or migrate wiki pages with attachments from one Azure DevOps environment to another – TopBullets.com

Topbullets.comGenerally, when we start a project, we tend to build git repo on our local environment (Microsoft free version) and when the team grows, we try to move to some other environment that might be paid or enterprise one. Recently, I faced a similar issue. Moving code repo was easier with few git commands but the real challenge came when I was moving wiki pages with attachments. Finally, after struggling for 3 hours, I found a solution that is nowhere available on the internet and I thought it is worth sharing with my audience. So, here it is – how to move wiki pages from one project to another.  

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:

DevOps Transfer

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.

DevOps Transfer Process

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”
Repo folders

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. 😊
Personal repo wiki

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”
Repo wiki clone

Wiki Clone

Git clone

Step 5: Now repeat steps 3 and 4 on your enterprise environment. There you just create a demo wiki with at least 1 image.
Enterprise demo page
Enterprise clone

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”
Image transfer

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.
Wiki page copy paste

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”.
Original order file
Update .order file

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.
Wiki push

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"
git status
git push

If you have many attachments say more than 10, it is impossible to add them manually so use the below code to upload them to git server.git status
git add .attachments/*
git commit -m "added attachment and update the wiki from personal"
git status
git push

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.

Final page

Signature

Deepesh Singh
logo

Advertisement

Please leave your valuable comment.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s