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?

2 answers

1 accepted

2 votes

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: ${space.name}")
    trashManager.emptyTrash(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?

Hi,

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 scriptrunner@adaptavist.com if you want more information, I can add you to a distribution list.

regards,

Mark.

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:

https://jira.atlassian.com/browse/CONF-30043

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

Regards,

Rodrigo

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

910 views 23 12
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