How to delete all rocketchat_uploads so far

Description

I am looking for a way to delete all file uploads server wide as I was using the server storage option and now we’re moving to Webdav and I’d like to keep the server size as small as possible. I’ve seen in Mongodb that there are 3 collections that probably are the target ones: rocketchat_uploads, rocketchat_uploads.chunks and rocketchat_uploads.files.

I was wondering if there’s an option in Rocket Chat to delete all files from the app / CLI / etc or if not, whether dropping the 3 collections could lead to a problem.

Server Setup Information

  • Version of Rocket.Chat Server: 4.0.0
  • Operating System: Ubuntu 20.04
  • Deployment Method: snap
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
    actual oplog size
    ‘990 MB’

configured oplog size
‘990 MB’

log length start to end
‘8013119 secs (2225.87 hrs)’

oplog first event time
‘Mon Jul 05 2021 17:47:36 GMT+0200 (Central European Summer Time)’

oplog last event time
‘Wed Oct 06 2021 11:39:35 GMT+0200 (Central European Summer Time)’

now
‘Wed Oct 06 2021 11:39:41 GMT+0200 (Central European Summer Time)’

  • NodeJS Version: v12.18.4
  • MongoDB Version: 4.0.20 / mmapv1 (oplog Enabled)
  • Proxy: nginx
  • Firewalls involved: no

Any additional Information

Stop crashing in on other old threads please.

A proper search will have found you a number of links on migrating files eg

That has a link to a migrator script which can also remove files, plus there is another similar script somewhere in the main rocketchat git repo with a link here somewhere.

1 Like

Thank you @reetp,
I was able to delete some old uploads in GridFS using this script

But still the size of the collection rocketchat_uploads.chunks is over 2GB (even setting the deletion of old files for everything older than a day)

I’ve tried the GridFS migrator that you mention, but without a previous migration that creates a log file, it does not seem to be able to delete the old files.

I’ve also briefly checked the script you mention in the main git: GitHub - RocketChat/filestore-migrator but it does not seem to offer that capability.

Any additional ideas? It seems my instance of RC is already using most of the 20GB that the server is offering.

Thank you

Hi!

I think you should first identify where are those 20G. Maybe it’s not in uploads?

I assume you have already configure the retention policy, right?