At Addteq, we like to blog about our experiences and share information with everyone to contribute to and improve the DevOps field. For many years, Addteq had successfully created and hosted blogs on Confluence. We were pleased with our workflow, where we could use the fantastic collaboration features of Confluence and some powerful apps for content creation. These tools allowed us to write the blog content in a dedicated Confluence space, approve, and publish it to a second space, automatically publishing it to our website, as we outlined in the blog post. As for our core website, we used static HTML generated by a javascript-based toolchain. However, as part of an effort to improve our SEO and streamline operations for Marketing, we decided to migrate to WordPress.
On the one hand, our marketing department felt most comfortable with Confluence. On the other hand, we wanted our content creators to retain the ability to collaborate on the content within Confluence itself instead of requiring them to switch gears and use WordPress directly. We planned to automate the process of publishing content from Confluence to WordPress, but we decided to launch initially, where we manually copy the content instead. The most significant effort involved with switching to WordPress was migrating our existing blog content and automating the migration process without copying and pasting all of our existing content manually.
Migrating Content
At a high level, we can divide the end-to-end migration into these steps:
Install the Docker client for Confluence CLI and run the following commands to export all the blogs from the space into a CSV file.
docker run -ti bobswiftapps/acli:latest /bin/bash
acli confluence --server https:
//confluence --user admin --password $PASSWORD --action getBlogList --space "BLOG" --outputFormat 999 | tee output.csv
Sanitize the CSV using custom bash scripts to perform clean-up, such as converting Confluence image XML tags into plain HTML tags.
Crawl all the images in the existing blog and download them to a directory accessible by WordPress using a custom Bash script.
- Create WordPress users using a custom BASH script that reads the Confluence users from a CSV file.
- Run a custom Bash script that leverages the WordPress Command Line tool, and publish the WordPress blog posts in a way that preserves all metadata like the original date published, title, authors, etc.
- Once published, spot-check the new posts and perform a complete UAT cycle before planning for production!
Step 1 is possible thanks to the Confluence Command Line Tool; the best and most versatile multi-tool administrators can use to automate most aspects of Confluence tasks. As demonstrated above, this tool can also help export content from Confluence. It also has capabilities to allow importing content into Confluence from other sources.
The custom bash scripts in Steps 3-5 rely on the excellent open-source WP-CLI tool, which is the equivalent of the tool above but for WordPress. We highly recommend using WP-CLI to automate WordPress migrations and administration.