Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

Confluence Attachments

Christopher Cannata April 9, 2014

Hello,

I have Confluence setup with attachments stored in a file system. I need to perform a cleanup of this system to free up space. Is there a way to do a search to find attachments in confluence file system that are no longer referenced on any Confluence page?

Also, is there a way to search througha list of of the biggest attachments and see what Confluence space or page they are being referenced in?

2 answers

1 accepted

1 vote
Answer accepted
NotTheRealStephenSifersNOPENOPENOPENOPE
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 9, 2014

There is a SQL query you can run in the back end to show attachtments with size:

use Confluence
select TITLE, PAGEID, FILESIZE/1024/1024 as MB
from dbo.attachments
order by FILESIZE DESC

Christopher Cannata April 9, 2014

Thanks, I had already ran that query. I have the full list, the problem I am running into is I need to know which attachments are no longer referenced (not needed and can be deleted) and then for the remainder I need to find a way to see what Space the active attachments are being used in.

Thanks,

Chris

NotTheRealStephenSifersNOPENOPENOPENOPE
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 9, 2014

When a space or page is deleted, the attachment is then removed from the space or page.

I am doing a little more digging to get you something a little more focused.

NotTheRealStephenSifersNOPENOPENOPENOPE
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 9, 2014

I am not finding an easy way to pull data from SQL to tell when an attachment is referenced within the page. The issue being there is more than 1 way to reference an attachment and multiple macros (not including custom ones) that also take advantage of an attachment.

The attachment page within a page is still part of the page itself, and even if an attachment is not referenced outside of the attachment page it is still technically used.

The best idea I can come up with for this one would be to delevlope a script to crawl through all attachment names and ID and scrub the pages to see if it's referenced.

But the issue with this is maybe an attachment is placed on a page for a reference or archive purposed. Granted storing items as an attachment for an archive is not a good idea, but that doesnt stop people from doing it.

Simply put, this will not be easy to complete but would be cool to see how you do it!

Christopher Cannata April 10, 2014

Is it possible to search the nonspaced directory for the attachments specifically for the global site logo, because that is all we would have in the nonspaced directory. I could then theoretically delete all the other attachments in the nonspaced directory.

NotTheRealStephenSifersNOPENOPENOPENOPE
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 10, 2014

You can do a search for null entries within SQL, but the issue is there is no page to delete them from since their not attached to a space or page. It's work a try.

To the above SQL just add "where PAGEID is NULL" between from and order. It may not work unless you LEFT OUTER join it with the content table and spaces table.

Christopher Cannata April 13, 2014

Had to do some modifications, but it worked well. Didn't free up nearly the amount of space needed, but I was able to figure out what space was using the most resources, so I can do further cleanup now. Thanks for the help.

1 vote
jing_hwa_cheok
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 10, 2014

Hi Christopher,


I believe this is what you are looking for http://ffeathers.wordpress.com/2013/06/02/how-to-manage-attachment-usage-in-confluence-wiki-with-some-python-scripts/. You can usethe python script there to find orphaned attachment.

Regards,
Jing Hwa


Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events