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
Posted Monday in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

104 views 3 4
Join discussion

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