How to automatically purge old attachements?

Yogi G April 12, 2012

Hi,

I want to know how to automatically purge the attachements which are 30days old?

I have checked in the attachement settings but it just gives me the location of the directory where attachements are stored.

Please help its urgent.

Thanks

Yogi

2 answers

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
April 12, 2012

Confluence Command Line Interface can be used to script a cleanup or archive policy. Use action getAttachmentList to get attachments create date and then removeAttachment to remove them. It would need to go through all the pages in whatever spaces you wanted to apply the policy to.

Saul Perdomo April 14, 2014

Hey Bob,

Is there a way to purge old JIRA attachments using your CLI plugin for JIRA?

Thanks!

Bob Swift OSS (Bob Swift Atlassian Apps)
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.
April 14, 2014

Yes, pretty much the same technique. Here is an example of getting the list. You might want to use --dateFormat to get the date in form easiest to handle in your script. I just ran this over 3000 issues myself for another purpose. all is a filter in this example. Filters should be used if number of issues > 1000 so CLI will do paging.

--action runFromIssueList --filter all --common "--action getAttachmentList --issue @issue@ --file attachmentList.csv --outputFormat 999 --append" --continue

Bob Swift OSS (Bob Swift Atlassian Apps)
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.
April 14, 2014

I should add that for either JIRA or Confluence, if you edit the resulting csv file that is produced to reduce it to just the attachments you want to remove AND remove the columns that are not needed by the remove command, then you can use runFromCsv to actually do the deletes without any scripting.

Lisa Dyer April 29, 2014

We've been trying to use the Attachment Tools plugin but no success. Bob, could your approach be used to delete or archive versions of all attachments such that only the latest version is ever stored?

Bob Swift OSS (Bob Swift Atlassian Apps)
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.
April 29, 2014

Yes, but, you would need a script to apply that type of logic as it is processing the list.

Tummalachervu Chaitu February 1, 2018

Hey Bob,

I have the same issue, I have some projects jira, where i would like to delete the attachment of all closed issues. Can you give me the steps please. there is no time specific, all i need is if i can give a project name all the closed issues should remove attachments

tifonas-katrina February 12, 2018

Hey,

I face the same issue. Need to remove attachments of closed issues before 2016.

How can I achieve this without having to do it manually?

Rajesh Ramankutty June 5, 2019

Hi 

 

The Same Question for jira Soft and Jira Core we need to move the Attachments automatically in server version.

0 votes
Ramiro Pointis
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.
April 12, 2012

I don't think that this is possible. The only way to delete from jira is inside every issue, and your user need to have the permissions to do that.

Other way could be erasing the attachment from the directory but this won't be automatically. You can search in Plugin Exchange to see if there's a plugin for this.

Yogi G April 12, 2012

Actually I have this issue in Confluence not in JIRA...sorry my mistake...

Ramiro Pointis
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.
April 12, 2012

OH! ok, that's a whole different thing :)

In that case, it's good to specify in the tags that it is confluence, for avoiding any mistake.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events