Restoring attachments from a File System backup when a Space is mistakenly deleted

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

The supported procedure is to restore a space export that contains the attachments included in it. Thus, Atlassian  cannot guarantee providing any support for the procedure below .

Purpose

This guide applies only if you have deleted a space by mistake, re-imported that space using the Space XML Backup (without attachments) and the attachments were recovered from the filesystem backup of the old space.

Solution

We already have a guide on How to resolve missing attachments however, this does not apply in the situation explained here because after we imported the lost space, we have a new space with new page and attachment IDs.

In this case, we have a set of IDs belonging to the new attachment hierarchy and the old attachment folders (which contain the attachments we want to recover), but there is no easy way of mapping one to the other. 

This solution requires that you have access to the Confluence repository backup before the space deletion. If you don't have access to it, there are minimum possibilities to restore the attachments.

Please, follow the steps below:

  1. You will need to run this query twice (make sure to replace the <SPACE_ID> in the query accordingly)
    1. The first time on the new database using the new space ID
    2. The second time on the old database using the old space ID

      SELECT contentid, 
             title, 
             lowertitle, 
             contenttype, 
             pageid 
      FROM   content 
      WHERE  contenttype IN ('PAGE', 'BLOGPOST') 
             AND contentid IN (SELECT pageid 
                               FROM   content 
                               WHERE  contenttype = 'ATTACHMENT' 
                                      AND prevver IS NULL 
                                      AND spaceid = <SPACE_ID>) 
      UNION 
      (SELECT contentid, 
              title, 
              lowertitle, 
              contenttype, 
              pageid 
       FROM   content 
       WHERE  contenttype = 'ATTACHMENT' 
              AND prevver IS NULL 
              AND spaceid = <SPACE_ID>) 
      ORDER  BY 4, 
                3; 
  2. This will fetch the page and attachment names along with their IDs
  3. Combined with the old and new space IDs, you should be able to construct the paths of the old and new attachments on the filesystem (based on this documentation Hierarchical File System Attachment Storage)
  4. After that, all you need to do is copy the attachments from the old path to their corresponding new path


Last modified on May 24, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.