projectdoc Toolbox

Rescue and restore data of a Confluence page that does not render anymore.

Audience
Type
Level of Experience
Expected Duration
10 min

Encountering a page in Confluence that no longer renders makes it not only impossible view, but also to edit it. The author has no means to correct the problem. If the log file is empty, the author not even has a clue what is wrong. How to rescue and restore such a problem Confluence page?

This tip shows you how using SQL.

Summary

This short tip has shown how to manually retrieve the page ID, different versions and the data in storage format to recover a page that can not be rendered in Confluence.

Access the Page in the Database

Using the following database select (here for a MySQL database) you can determine the Page IDs (aka Content IDs) of all versions to this page.

SELECT BC.CONTENTID, C.VERSION, C.PREVVER 
FROM BODYCONTENT BC JOIN CONTENT C ON BC.CONTENTID = C.CONTENTID 
WHERE C.TITLE = 'TITLE OF PAGE';
+-----------+---------+-----------+
| CONTENTID | VERSION | PREVVER   |
+-----------+---------+-----------+
| 100664427 | 4       | NULL      |
| 100664428 | 1       | 100664427 |
| 100664429 | 1       | 100664427 |
| 100664466 | 2       | 100664427 |
| 101515286 | 3       | 100664427 |
+-----------+---------+-----------+

With CONTENTID 100664427 being the latest one as the version is the largest number and the value in the PREVVER column is NULL.

Access the Page via the User Interface

Now use this URL (please prepend the server like https://my.example.com):

/confluence/pages/viewpage.action?pageId=xxxxxxxx
View the version of the page you identify with the ID.
/confluence/pages/diffpagesbyversion.action?pageId=xxxNEWESTxxx&selectedPageVersions=3&selectedPageVersions=2
View the differences of two versions of a page.
/confluence/pages/editpage.action?pageId=xxxxxx
Open the page in the editor.

Access Page in the Database

If these options did not help to retrieve the content, it can be saved to a text file by using the following statement:

SELECT BC.BODY FROM BODYCONTENT BC JOIN CONTENT C ON BC.CONTENTID = C.CONTENTID 
WHERE C.TITLE = 'TITLE OF PAGE' AND C.PREVVER IS NULL 
INTO OUTFILE '/tmp/save.source';

References

Related article on the smartics blog:

Editing Corrupt Pages in Confluence
While writing macros for Confluence I encountered a problem that prevented the wiki to render the page. Without the edit button showing up on the “Oops” page, I first thought that I will never see the contents of the page again. But the story came to a good end!  And without accessing the database …!