Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to purge attachment history?

Brett Ryan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2012

We have a situation where our attachment growth is expanding quite rapidly as users are utilising Confluence as a collaboration tool around office documents. Due to this the prior versions quickly build up which turns a file of a few MiB in size to a few hundred MiB.

I'm wondering if there is a third-party plugin or some way you could let me know to periodically purge history? We would ultimately like to be able to purge history within a designated period of time.

Looking at our attachments table shows there is a moderate 3,561 attachment documents, of this there are a total 4,953 when counting prior versions.

I could quite simply use a mechanism in SQL to print and purge content with a query such as:

select attachmentid,
       title,
       pageid,
       creator,
       lastmoddate
  from attachments
 where prevver is not null
   and datediff(curdate(), lastmoddate) > 30;

And then delete the subsequent attachment file, however I would gather there are two problems to this:

  1. Confluence would need to be off-line
  2. Lucene cache would need to be rebuilt (maybe?).

I'd really prefer not using this method unless it's proven to be safe.

If there are no other ways, no plugins etc, I'd be happy to investigate writing such a plugin provided the api's are available from within confluence to delete prior versions. If they are, could you kindly point me in the right direction to get me started on this? My plugin authoring experience has currently been only for themes and macros.

4 answers

1 accepted

3 votes
Answer accepted
Brett Ryan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2012

I have decided to solve this by creating a plugin with a schedule to purge attachments as needed.

Available on github.com you can find the Attachment Tools Plugin. I should be releasing a version later this week.

Sorin Sbarnea (Citrix)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2014

Hi Brett, Does you plugin still works with Confluence 5.4? Last change was made more than two years ago so I think it makes sense to ask :)

Infrastructure_Administrator
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 20, 2014

Hi Sorin the plugin should work fine on 5.x and I have tested on an earlier 5.x version previously but have not updated the plugin.

Internally our company has had many issues with many plugins moving to 5.x and are still on 4.x ourselvs. Atlassian really created a nightmare with 5.x that we still aren't happy about.

I hope to start looking at this soon actually and we should have something verified for 5.x releases within a month.

Brett Ryan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 20, 2014

Hi Sorin the plugin should work fine on 5.x and I have tested on an earlier 5.x version previously but have not updated the plugin.

Internally our company has had many issues with many plugins moving to 5.x and are still on 4.x ourselvs. Atlassian really created a nightmare with 5.x that we still aren't happy about.

I hope to start looking at this soon actually and we should have something verified for 5.x releases within a month.

0 votes
Brett Ryan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2012

I've just finished the plugin, was working fine in report mode, so decided to turn on the deletions.

Little did I know that calls to AttachmentManager.removeAttachmentFromServer(Attachment) remove ALL VERSIONS.

This is a huge setback for me as I now spent three days writing a plugin only to find that the one method I need doesn't behave as I first thought.

Looking at com.atlassian.confluence.pages.persistence.dao.hibernate.NonTransactionalHibernateAttachmentDao reveals the following:

if (!attachment.isLatestVersion())
{
    attachment = (Attachment) attachment.getLatestVersion();
}

Sad face. Really sad face :(

0 votes
Brett Ryan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2012

Thanks Matthew, have decided to write a plugin for it. Just need to figure out how to email results and it will be pretty much complete. If you know how to send email from confluence it would be a big help :)

0 votes
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2012

I don't know of a better way, but Confluence would not have to be off line to run your purging query. The cache would need to be rebuilt, though.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events