Database & Data directory are out of sync

Hi all,
I am running NextCloud and using AWS S3 to store my files. When I delete files & then purge the trash the files no longer appear in NextCloud as expected. However, the files are never purged from S3. So now, I need to identify the & remove from S3 files whose records are now gone from the DB.

Please tell me there is a painless way to do this.

If there isn’t, what is the best approach?
I thought I’d list all the file objects in S3 then compare those file names with the entries in the fileid column of the oc_filecache table.

For reference all my files in SD are named urn:oid:SOMENUMBER
Where SOMENUMBER is mapped to fileid on the oc_filecache table, I think.

Any help is appriciated.
Thanks,
Greg

If I read you correctly files are never removed from the S3 bucket, even when it is completely deleted?

To my knowledge the number of oc_filecache > fileid corresponds to the number of the file in your S3 bucket ( urn:oid:[fileid] ).

If what you say is correct I’dd assume a script reading all the files in the bucket and checking if the number exists in oc_filecache > fileid would be the way to go to check for “old crap”?

Sorry i do not use S3.

But i found this issue.

Perhaps this entry solves a part of your problem. Test it on your own risk:

sudo -u www-data php occ trashbin:clean --all-users
Files are not deleted from S3 (primary) · Issue #20333 · nextcloud/server · GitHub

Unfortunately I do not fully understand the connection between trash and the difference between database and S3. Maybe it is a part of the difference.