Solution for automated trash purging? Edited

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

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. 

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. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

893 views 2 13
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you