Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Trash Purge all across spaces

Deleted user July 17, 2013

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

2 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2013

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.

Deleted user July 25, 2013

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

Enterprise Procurement December 17, 2015

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

M Hoogenboom April 18, 2016

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?

Mark McCormack _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2016

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

Anderson Hsu July 7, 2020

Hi all, 

How can I use it in confluence 4.2.3 version ? Would it be possible to give suggestion about how to clean trash automatically? Thanks a lot.

1 vote
Rodrigo Girardi Adami
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 18, 2013

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

Anne EQS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 25, 2016
0 votes
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 28, 2018

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events