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:
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.
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.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.