Trash Purge all across spaces

We're running v 5.0.7. I'm attempting to do some disk space recovery. I know under Space Admin I can go into each Space and purge trash, however, is there a way to do this from a global level?

3 answers

1 accepted

You could...

* Install the Script Runner for Confluence
* Go to Admin -> Script Console

then paste in and run the following script:

package com.onresolve.confluence.scripts

import com.atlassian.confluence.pages.TrashManager
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.confluence.spaces.SpacesQuery
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal
import com.atlassian.spring.container.ContainerManager
import org.apache.log4j.Logger

def log = Logger.getLogger("com.onresolve.confluence.scripting.EmptyTrashAllSpaces")

def trashManager = ContainerManager.getComponent("trashManager") as TrashManager
def spaceManager = ContainerManager.getComponent("spaceManager") as SpaceManager

def spacesQuery = SpacesQuery.newQuery().forUser(AuthenticatedUserThreadLocal.getUser()).build()
def allSpaces = spaceManager.getAllSpaces(spacesQuery)
allSpaces.each {space ->
    log.warn("Empty trash from space: ${}")

"Emptied trash from ${allSpaces.size()} spaces."

This is probably well worth doing periodically actually... I ran it on a copy of one of my production instances, and got back a lot of space in the database.

It can take a while... tail the log to see progress.

I'll be looking into using this! I think it really should be part of base functionality.

This solution doesn't work as of confluence 5.9.1 since script Runner for Confluence is no longer available or working.

Just found that out as well. @Jamie Echlin (Adaptavist), do you know an alternative for Script Runner on Confluence or plan to deliver this from Adaptavist in the future?


We've been working on ScriptRunner for Confluence this year and we are aiming to have a release ready for Atlascamp (so about 5 weeks) all going well.

Feel free to email if you want more information, I can add you to a distribution list.



ScriptRunner - PM

1 vote

Hi Denise,

I didn't found a way to do this with the current version of confluence, so I have created a feature request for you:

I recommend to vote and watch it to increase the chance to be implemented. I hope this helps!



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...

276 views 2 10
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