How to export Confluence Questions Content to CSV Through the Database
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This guide is for informational purposes and is not eligible for support as part of the Atlassian Support Offerings. If you have any questions about the information on this page, please reach out to our Atlassian Community for help.
This guide will help you exporting the whole content generated in the Confluence Questions plugin to a CSV file by running a query against the application's database.
Solution
This process requires the use of direct database manipulation and is not part of Confluence's intended functionality. As such, this process is not covered under the Atlassian Support Offerings and the information on this page is provided as-is. It should be thoroughly tested in a development or staging environment before implementing any changes in your production instance.
This query was written to be used in PostgreSQL. If you're using another DBMS, it might be necessary to adjust the query to use the specific functions of your DBMS.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
COPY (SELECT c.contentid AS "ID", c.parentccid AS "Parent_id", (CASE WHEN c.pluginkey = 'com.atlassian.confluence.plugins.confluence-questions:question' THEN 'QUESTION' WHEN c.pluginkey = 'com.atlassian.confluence.plugins.confluence-questions:answer' THEN 'ANSWER' WHEN c.pluginkey = 'com.atlassian.confluence.plugins.confluence-questions:comment' THEN 'COMMENT' END) AS "Type", c.title AS "Title", bc.body AS "Content" FROM content c INNER JOIN bodycontent bc ON c.contentid = bc.contentid WHERE c.pluginkey IN ('com.atlassian.confluence.plugins.confluence-questions:question', 'com.atlassian.confluence.plugins.confluence-questions:answer', 'com.atlassian.confluence.plugins.confluence-questions:comment') ) TO '/tmp/questions.csv' WITH CSV HEADER DELIMITER ',';
Note that the path at the end of the query is set to /tmp/questions.csv. This will save the file in your /tmp/ directory in a Unix environment, with the file named as questions.csv. If you're using Windows or want to change the path, please update this before running the query.
Was this helpful?