Migrate SharePoint Blog to WordPress

Migrate SharePoint Blog to WordPress

As promised here, this is a follow-up post with the tool I developed for the SharePoint to WordPress migration.

First, a screenshot:

Migrate SharePoint ot WordPress Screenshot

What is it, that we have to cover with a migration? Copying the posts is not enough. So I came up with this features:

Features

  • Copy posts
  • Copy comments
  • Copy resources like images and downloads
  • Create needed tags and categories
  • Modify links to local resource
  • deal with https, if links are absolute on the source blog and mixed with http
  • Using web services to connect to source and destination
  • URL rewriting (covered by a WordPress Plugin)
  • Delete all content from the destination blog (for migration testing)
  • Replace strings (with Regex)
  • a nice (WPF) GUI

Description

Originally I’ve build a plain console application. Then I thought that a console application would possibly scare some users. And after some time I wanted to do some WPF again. So I created a WPF application, to wrap all the functionality into a GUI. This way it will be easier to use for the folks out there, who do not like black console applications 😉 Since I am using web services to connect to both blogging platforms, the tool can be executed on any client computer. No access to a server session is required.

To start, you obviously need URLs to the source and destination blog, as well as credentials to the destination blog. Since most blogs are anonymous, you’ll probably not need to fill in the source credentials. The migration starts by hitting the “Migrate Content” button. That should be it for using the tool. It will remember the last entries for the URLs and login names, in case you need to perform multiple runs, which was the case for me. The passwords will need to be reentered for security reasons.

It’ll show the progress of all steps in a progress bar and text at the bottom of the application and tell you when it’s finished. Existing categories are mapped to new categories and used as tag, too. I’ve tested the tool with three blogs, one being my own with installed CKS:EBE. There really isn’t much more to configure, to have your blog being migrated to WordPress with this tool.

Some data needs to be modified, before the blog can go live on the new destination. In case of URLs this is necessary to generate valid links within the destination. Fortunately there is a plugin available to do some fancy rewriting. Since WordPress is showing its own smilies, I wanted to get rid of some strings within the posts, that reference smilies as images and replace them with, well, smilies. A txt file within the same directory with the name “replacestrings.txt” will take lines with strings for replacement.

The sample will replace all my old smilie images with plain string before posts are created on the destination blog. The images that were used as smilies in the source, won’t be copied to the destination, because they are not referenced anymore. Otherwise I got many images with smilies. I like smilies 😀

You can stop reading here, if you are a user and would like to migrate your blog and download the tool. As a developer you might be interested on how the tool works…

Technical stuff

The tool gives me a good opportunity to explain some programming tasks, I used for the migration tool. I will explain some of them.

SharePoint offers web services (_vti_bin/lists.asmx), WordPress an XML RPC interface (I used CookComputing.XmlRpc to connect). Those two are used to connect to the blogs. Since the SharePoint web services need Displaynames to connect to the posts and comments list, I first queried them by list template.

Querying SharePoint for List Titles

Use the SharePoint lists web service, to get all lists of a site and search for specific lists like the posts and comments. The lists are identified by the used template. That way I do not have a localization issue.

With the list names retrieved, I can query the lists for data. The web services use display names to identify lists.

Get SharePoint items with paging via web service

The method to actually query the web service for listitems. Properties of the class SharePointListConfig for the list title, ListItemCollectionPosition and Pagesize are simple string properties. The fields are specified, to get only the data we need for the migration.

After all data has been read, local resources parsed and links replaced we move on to the destination side.

WordPress specific details

As stated above, I’ve use an existing library. There are plenty of samples out there, if you look for them. I’ve implemented the following methods.

I would like to tell you some issues I had, so you don’t get the same problems I had programming with the WordPress XML RPC interface.

Post deletion

Just call the wp.deletePost method? Almost. You’ll have to call it twice to first move it to the recycle bin and then again to have posts being deleted permanently.

Media deletion

There is no method to delete items from the media gallery 🙁 Fortunately items within the gallery behave like pages. So if you implement an call the deprecated wp.deletePage interface, you can achieve what you want (remember to delete twice).

Categories and Tags

Both can be managed with the interface for terms the string for the parameter “taxonomy” will decide what to do. It can be “category” or “post_tag”.

Other than that, the WordPress API is pretty straight-forward and easy to use.

Download

The download contains an executable, which is the tool itself, and a folder with the complete sourcecode.

Migrate SharePoint To WordPress

20 Comments

sharepoint digital signature

Reply

You just made something that I thought was so difficult be, truly, so easy! Thanks for the post!

 

    René Hézser

    Reply

    You are welcome 🙂

     

Robert Bogue

Reply

Thank you for the tool — I’m getting an error (404) — I was planning to go through the code and see what I could do to figure out the problem but I was wondering if you might be up to an email conversation so I can get you the updated code when I hunt down the problem.

 

    René Hézser

    Reply

    Hi Robert,
    if you would like to supply improvements, you can contact me through the contact form (“Kontakt”).

    René

     

David Smith

Reply

I’m having an issue getting the tool to connect to SharePoint online. I’ve used the public DNS name of my website PLUS I’ve tried the O365 tenant name (tenantname-public.sharepoint.com) and consistently get Access Denied.

Thoughts?

 

    René Hézser

    Reply

    Hi David,
    I did not test the connection to SharePoint Online.
    Currently my sparetime is very rare, so I can’t look into this. sry 🙁

    René

     

Charlie Smith

Reply

I ran across you tool when I got a request to move a SharePoint blog to WordPress.

I did run across one small issue during the post retrieval process. The “Published Date” column is not required and may be empty. I’m guessing SharePoint substitutes “Date Created.” I simply wrapped you code to Convert.ToDateTime in a try/catch block and everything was good.

My problem now is trying to connect to WordPress. I’ve doubled the credentials and they are correct but I continue to get a 403 error during the “Creating Categories” phase.

Any ideas where I might being looking for the real problem?

Thanks

 

Eric Stepek

Reply

Tried executing the tool against a Sp2013 SP1 Blog site and received the following error:

Could not load file or assembly ‘CookComputing.XmlRpcV2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.

Where is this DLL available from?

 

    René Hézser

    Reply

    Hi Eric,
    the assembly is within the solution items folder.

    Regards
    René

     

      Stéphane Pépin

      Reply

      Received the same issue as Eric, was there a solution for this? Thanks

      Could not load file or assembly ‘CookComputing.XmlRpcV2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.

       

David Herries

Reply

hi

any chance I could get you to complete this as a paid service for our website?

Thanks in advance.

 

    René Hézser

    Reply

    Hi David,
    did you try the tool? It should be easy to use.
    René

     

Laura Rogers

Reply

Hi Rene,
I’m getting the same error as Eric above, regarding the DLL. What’s the solution to the error? I’ve tried this on multiple computers and operating systems, and I’m not sure how to fix it.

 

    René Hézser

    Reply

    Hi Laura,
    copy “CookComputing.XmlRpcV2dll” from the folder “ExportToWordpressSolution Items” to the root folder where the MigrateSharePointToWordPress.exe lies.

    René

     

Andi Fandrich

Reply

Hallo René,
auch von mir ein herzliches Dankeschön. Stand vor genau demselben Problem und habe mich u.a. wegen Deines Tools für WordPress entschieden 😉
Gedownloaded, getestet und wie erwartet auf den ersten Rutsch alles gut.
Danke nochmal und viele Grüße
Andi Fandrich

 

Martin

Reply

Hi, your tool looks very promising. Unfortunately on my blog it dies with error:

Creating categories
Response contains invalid XML

That’s all there is. On wordpress i can see one category successfully created and the XML reply is this:

5

Where ‘5’ might be the ID of the newly created category – just guessing …

So any idea why it complains about invalid XML ?

How can i debug this further? Does your tool provide any verbose logging?

Thanks in advance.

 

    Martin

    Reply

    Here is the XML response:

    5

    And yes, 5 is the id of the newly created category. So this should be no error for your tool?

     

Stephane Pepin

Reply

Wondering if you can help. I’m using your tool and seems to function, however I get a 401 error when it attempts to create posts, but it does create the categories?

Connecting to ‘…’ to get lists…
Reading Posts…
Got 571 posts. Now fetching comments…
Got 1295 comments and added them to their posts.
Found 530 posts with references to local resources.
Creating categories…
Creating posts in WordPress…
The remote server returned an error: (401) Unauthorized.

Thanks

 

Benoit HAMET

Reply

Hi René
thanks for your tool
I’m moving too from my SP blog to WordPress
Your tool seems quite good but I’m facing an HTTP 404 error at the ‘Creating posts in WordPress’ step as show below
The categories have been successfully created
Any idea?

Reading Posts…
Got 1027 posts. Now fetching comments…
Got 81 comments and added them to their posts.
Found 650 posts with references to local resources.
Creating categories…
Creating posts in WordPress…
The remote server returned an error: (404) Not Found.

 

Leave a Reply