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

This widget could not be displayed.

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

This widget could not be displayed.

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!



This widget could not be displayed.
Gonchik Tsymzhitov Community Champion Aug 28, 2018

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

565 views 7 6
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