Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Solution for automated trash purging?


Hi there,

is there some Confluence plugin or another solution (or way) to purge pages from the confluence trash bin after a specific amount of time (trash date + x days)?

Are there *any* ways to automate permanent deletion dependent on criteria such as "trashed" date, "created" date etc.?

Thank you!


2 answers

I looked into a possible solution using the Archiving Plugin, but that doesn't seem to be an option. Problem: We needed a two-step workflow:

Step 1: User archives a page manually by assigning the "archive" tag OR a page is archived autoimatically by specific filter crieteria (OK, will work).

Step 2: The Archiving Plugin scans its own archive space to permanently delete all pages that are older than 90 days.  (that one won't work)

However, Step 2 doesn't seem to be possible, as the Archiving Plugin is not able to use its own Archive spaces as input. Even after making such spaces visible by changing their status from "Archived" to "Current", the Archiving Plugin is not able to assign workflow rules to its own Archive spaces. 
Or did I miss something?

(NB. you should have been added your comment as a reply to my answer in the top, not as a new answer. Now the context is somewhat lost.)

So, permanent deletion is a primary requirement? So must the content go forever?

I am asking this, because our add-on is built more with the mindset of "archive this content, so that it becomes invisible, but when it is necessary, it can be searched through, it can be viewed, it can be restored". The motto is: "don't delete, archive instead as you can never know".

Oh sorry. WIll do the next time.

Yes, permanent deletion is a primary requirement. 

Basically, the requirement for now is that if the user deletes a page, it should be recoverable for x days, but not visible to the normal user anymore and not available for standard searches. After those x days, it should be deleted permanently automatically. This has legal reasons is thus a hard requirement.

In my use case, when using your plugin, archiving would be kind of a workaround for the lack of an automated way to purge the trash bin in a way that a page is deleted from the trash "x days after it has been trashed".

I think your plugin could help in that situation, if it could two two more things:

- Apply archiving rules also to already archived pages, i.e. that an "... (Archive)" space would be (optionally) visible to the archiving rules form, even if the space is set to "Status = Archived" (which would be required, too, to avoid search matches from these archives)

- If there was an additional "Archiving strategy", that takes care that content is permanently deleted. Maybe don't call it "archiving" then. ;-) In some companies, there are such (legal) requirements. If you add such features to the plugin, it could be very valuable to such companies, especially since there doesn't seem to be another available solution yet.

Thanks for elaborating the use case, Daniel!

Based on your explanation I created 2 public feature requests in our tracker and I encourage you to vote on these:


In addition to our product vision, user votes significantly affect the product roadmap.

Final note: I understand that the law requires you to permanently destroy content and that must go forever. But, those pages will be captured in Confluence backups and your database backups anyway. Is that compatible with the law?

Thanks Aron. For ease of implementation, "permanent deletion" could be implemented as another "Archiving strategy", however, my guess is that this is not too intuitive for new users, so it might be better to make this a new area on the archiving rules setup page and not list it as an "Archiving strategy", but rather a new rule what to do with a page.

The issue with backups is addressed already: No backups older than x days are kept at all. ;-) 


Hi Daniel,

Using ScriptRunner for Confluence as mentioned before you can establish using a Script Job what is the frequency that the check is made, meaning you can say that you want to purge the trash after 30 days of pages being in there.

Let me know if you need help with that.



How can you flush a single page from the trash?

If you cannot, then the trash cannot be used for this use case.

For example, if you put page "A" to the trash on 1 Jan, then page "B" on 5 Jan, and you completely empty the trash on 1 Feb (30 days after "A" was trashed), then "B" will also be flushed although it was 25 day old only  -> PROBLEM!

Rafael, Aron is right, I need to scan every single page in the trash and decide, depending on its "trashed" date, if it's going to be deleted permanently or not in the current script run. Is this possible? 


Hi Daniel,

We had a similar question before from other customers and unfortunately Atlassian does not provide a timestamp when a page is trashed.

What you can do to make it work is to listen to the PageTrashEvent, add a content property to the page setting the date that was trashed and then use a Script Job to go through all these pages.

Hope it was clear,


Rafael, it still doesn't give an answer to my question:

How can you flush a single page from the trash?

DefaultTrashManager has a purge method with the following signature:

public boolean purge(String spaceKey, long contentId)

ContentId is the id of the page.

Rafael, do you mean there is no trashed date provided in an API by Atlassian or is there not even a trashed date stored in the Confluence database?

There isn't even a trashed date stored in the database :(

As I mentioned, you can implement yours, but it's not provided by Confluence. Shocking I know...

> DefaultTrashManager has a purge method with the following signature:

Ah, OK, cool! I didn't know about that.

Thanks guys, I'll see and discuss internally how we will proceed. 

Hi all, 

How can I use it in confluence 4.2.3 environment? Kindly help give suggestion about how to clean trash automatically? Thanks a lot.

Regards, Hsu Yao Chang

@Rafael Franco Thanks for the info on Scriptrunner for Confluence and the ability to purge specific pages from the trash. I have a few questions:

  • If I understand correctly, you would use a listener to identify any deleted pages and then add a content property to capture the date it was deleted and then use the DefaultTrashManager to delete pages by content ID that have a content property older than say 90 days. Is that correct?
  • Is the listener a built-in listener? Or can you provide the code to build out the listener that would put the date on the page?
  • Is the DefaultTrashManager a built-in script? Will it analyze the content property and be able to evaluate which pages are older and a certain number of days and then return the list of content IDs of pages that should be deleted?
  • Would this approach work also for attachments that are in the trash?

Thanks so much! We're evaluating options to delete items in the trash that are older than x days. We love Scriptrunner for Jira, but don't yet have Scriptrunner for Confluence.


0 votes

You can empty trash periodically using the ScriptRunner app, as explained here.

As for emptying only certain pages from the trash, I don't think you can do that. It is "nothing or all".

If you need more sophisticated page lifecycle tracking (based on last modification, last view, manual markers, etc.) and automated archival, check out the Archiving Plugin.

Thank you Aron, I'll have a closer look at the Archiving Plugin. It looks very useful on first glance. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

148 views 1 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you