Restoring attachments from a filesystem backup to an imported space

Still need help?

The Atlassian Community is here for you.

Ask the community

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 this case because after we imported the lost space, we have new space as well as 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. 

tip/resting Created with Sketch.

This solution requires that you have access to the DB backup before the space deletion. If you don't have that then there's nothing much we can do here.


  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 Mar 21, 2024

Was this helpful?

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