Recovering Database Attachments

Still need help?

The Atlassian Community is here for you.

Ask the community

This utility is for troubleshooting purposes only. It will not leave your production instance in a valid state. It's for extracting attachments from the database for recovery purposes.

Symptoms

Errors are thrown during Attachment Migration.

Cause

The attachments in the database or file system are in an invalid state (there are duplicates, for example), or the job is failing due to memory or swap-space issues.

Resolution

If the built-in Attachment Migration is failing, several tools can help:

Logging

OutOfMemoryException during migration

If you receive an OutOfMemoryException during the migration, download the attached migrationFix.zip class archive, shut down Confluence, and extract it directly into the <confluence-install>/confluence/WEB-INF/ directory. Once Confluence has restarted, try restarting the attachment migration from within the UI.

Attachment Migration JSP

If migrating from the database to the file system, save the attached jsp file to your <confluence-install>/confluence/admin directory and access http://<server_base_url/admin/migrate_attachments_from_db.jsp. This jsp helps identify which attachments may be problematic, and does the migration one by one if necessary.

(warning) If you are using Confluence 3.4, or if you are using an earlier version and receive a compile error referencing 'bucket.container.ContainerManager,' please instead use this updated jsp and remove the jsp encountering errors from the admin directory.

Make sure to perform this migration in a test instance. Once it's done, change the setting manually:

  1. Run:

     SELECT BANDANAVALUE FROM bandana WHERE BANDANAKEY = 'atlassian.confluence.settings';
  2. change the line to

     <attachmentDataStore>file.system.based.attachments.storage</attachmentDataStore>
  3. Run

     UPDATE bandana SET BANDANAVALUE = 'paste here' WHERE BANDANAKEY = 'atlassian.confluence.settings';

    When stored on the database, the attachmentDataStore will be set to database.based.attachments.storage

Additional Troubleshooting

If you receive the error:

caused by: net.sf.hibernate.WrongClassException: Object with id: 29491201 was not of the specified subclass: com.atlassian.confluence.core.ContentEntityObject (Discriminator: GLOBALDESCRIPTION)
at net.sf.hibernate.loader.Loader.getInstanceClass(Loader.java:660)

Delete the Global Logo from the ATTACHMENTDATA table:

You'll need to reupload your global logo afterwards, so save it before deleting if necessary.

delete from attachmentdata where attachmentid in (select attachmentid from attachments where pageid in (select contentid from content where contenttype = 'globaldescription'));
delete from attachments where pageid in (select contentid from content where contenttype = 'globaldescription');

The How to resolve missing attachments in Confluence utility may be helpful as well.

Last modified on Feb 23, 2016

Was this helpful?

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