migrate html content into confluence
Asked by Ray DR:

I am trying to migrate an old Knowledge Base into Confluence but I can only get the content as HTML files inside of an SQL dump.  
Is there any way I can migrate all of the articles in the SQL dump into a Confluence space?  
I have tried UWC but it does not recognize SQL DB's.


Answers:
author: Bob Swift (personal)
body: It depends on how you want the HTML content retained and whether it is a one time import. There are a few choices.

1. Create pages with the HTML content imbedded in an html macro. Either use the system supplied html macro (must be enabled) if you only have trusted users on your site or use the [HTML Macro](https://bobswift.atlassian.net/wiki/display/HTML/HTML+Macro) included with [HTML for Confluence](https://bobswift.atlassian.net/wiki/display/HTML) that can be secured with [Macro Security for Confluence](https://bobswift.atlassian.net/wiki/display/CMSP). You can use the Confluence SOAP or REST apis to create the page content if you have those skills or use [storePage](https://bobswift.atlassian.net/wiki/display/CSOAP/Reference#Reference-storePage) from [Confluence Command Line Interface (CLI)](https://bobswift.atlassian.net/wiki/display/CSOAP).
2. Put the files in the file system so they can be referenced by the [HTML Macro](https://bobswift.atlassian.net/wiki/display/HTML/HTML+Macro) (can't use the built-in html macro) and then create your pages as in 1) except the page content would just be a single [HTML Macro](https://bobswift.atlassian.net/wiki/display/HTML/HTML+Macro) with no body that references the file as a parameter.
3. Attach the files to Confluence. For instance, using [addAttachment](https://bobswift.atlassian.net/wiki/display/CSOAP/Reference#Reference-addAttachment) from [Confluence Command Line Interface (CLI)](https://bobswift.atlassian.net/wiki/display/CSOAP). Do the same as 2), except reference the attachment instead of the file system.
4. If your html is really clean (well formatted) and you only need to do the import once, you might be able to import it directly into a page (without using html macro) using [storePage](https://bobswift.atlassian.net/wiki/display/CSOAP/Reference#Reference-storePage) with the noConvert option.

comments: author: Ray DR
body: I am glad to hear I have some options. I will look into these. Thanks!


author: Alex Medved _ConfiForms_
body: Hi,

How I would approach this problem:

* Will extract the HTML content from the SQL dump into files and will create the directory structure I want/need
* Will create an empty new space in Confluence
* Will write a simple script that will traverse the files and will use Confluence REST API to import each file as new page <https://docs.atlassian.com/confluence/REST/latest/#d3e865>

A little bit of work, yeah... but not that complicated :wink:

comments: author: Ray DR
body: Thanks! I will check this out.So how will this work if I have a template in the Confluence space I want to use so all articles are organized in the same way? I know that all new articles going forward will use the template but I am not sure if an import can be told to use a template format.


author: Alex Medved _ConfiForms_
body: So, you get your Template as HTML and merge it with the HTML from the file and use the merged result to put it inside confluence (via rest api as mentioned earlier)


author: Ray DR
body: How would I tackle the first bullet you listed (extract the HTML content from the SQL dump)?


Tags: html

knowledge-base

migration

sql