# Uploads not getting orphaned and purged

**URL:** <https://meta.discourse.org/t/uploads-not-getting-orphaned-and-purged/259036>\
**Category:** Product Support\
**Created:** [March 22, 2023, 1:47pm UTC](https://meta.discourse.org/t/uploads-not-getting-orphaned-and-purged/259036 "2023-03-22T13:47:52Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Uphill4721](https://avatars.discourse-cdn.com/v4/letter/u/f19dbf/32.png) [@Uphill4721](https://meta.discourse.org/u/Uphill4721)\
**Post date:** [March 22, 2023, 1:47pm UTC](https://meta.discourse.org/t/uploads-not-getting-orphaned-and-purged/259036/1 "2023-03-22T13:47:53Z")

</div>

Hi,

Recently I ended up being the last remaining admin and maintainer of a basic Discourse Docker image instance that was originally installed on our server in 2021 (I think) and mostly updated by someone else. For some time now, possibly right from the start we’ve been having a problem with uploads from soft-deleted posts not getting orphaned and purged and I’ve been trying to troubleshoot this issue again for a few days as the obsolete files keep piling up and wasting storage space. We are not using S3 and there’s plenty enough storage for the uploads that we actually want to keep available.

I’ve migrated the full Discourse backup file including uploads to a separate staging server for testing by rebuilding with our app.yml following the official Discourse Docker installation guides and after that restoring the backup from commandline. Both installations seem to be running identically fine with no other obvious problems, but the upload issue remains.

I can’t seem to find any relevant errors from any logs and Sidekiq is running the cleanup jobs as scheduled. I have run `rake db:migrate` on the staging version and rebuilt many times, tried destroying posts permanently and checking settings. After permanently deleting some posts straight from the rails console and trying to run the cleanup job manually, I noticed that the tombstone directory had grown in size just a little at some point and there was some files to begin with anyways so the mechanism must’ve been working in some situations, right? Judging from the small size increase, almost all of the obsolete files are still not detected as orphans.

Current relevant admin panel settings listed below. Can I set the last ones to 0 to effectively skip the grace periods during testing?

> clean up uploads = true  
> clean orphan uploads grace period hours = 1  
> purge deleted uploads grace period days = 1

**How can I troubleshoot this efficiently?** I’m comfortable with the commandline but my database skills are rudimentary, so I’d really appreciate some tips to avoid going through every possible server setup detail without a clue about what I’m looking for at this point.

I’ve been desparately searching and reading this forum for similiar cases, but there’s only a few and those threads appear to stop either to a dead end or manual solutions for single files, so not directly suitable for this usecase.

Please ask me for more details if needed, I’m doing my best to solve this for good.

---

_[View the full topic](https://meta.discourse.org/t/uploads-not-getting-orphaned-and-purged/259036)._
