Nextcloud exclude files/folder from trashbin (deleted files)

Hi All,

I’m new here and try to find some help with my first post :slight_smile:
My own Nextcloud Server is running for years now, and it is working perfect.

Besides my normal data, my phone stores the signal backup in Nextcloud. The filename is “signal-2022-01-16-16-15-03.backup”.
Every day, a new file gets uploaded, and the old one will be deleted.

All the deleted files are landing in the trashbin and here is the Problem!
Let’s assume we have 3,5GB per file and they will stay for 180 days. This is 630GB of space!

Here are some ideas, how I would like to prevent this:

  • Exclude a folder from the trashbin.
  • Exclude a specific pattern from the trashbin, like “singal*.backup” (maybe admin config)
  • I also played around with flows, but found no solution.

Does someone have an idea how to handle this situation?

Thank you all :slight_smile:


Some details to my System:
Nextcloud version: Nextcloud Hub II (23.0.0)
Operating system and version: Ubuntu Linux 20.04.3
Apache or nginx version: 2.4.41
PHP version: 8.0.9

Hi, have you set a retention on your trashbin? you can auto delete after x days etc
https://bayton.org/docs/nextcloud/nextcloud-hoarding-trash-how-to-force-automatic-removal-of-deleted-items/

Hi, yes I’m using a retention of 180 days and if possible I would like to keep it at this value. If I lower it, this would also affect other files, like deleted office documents. Which I would like to keep for a while, just to be on the save side.

Perfect would be, if you could configure multiple retentions with patterns.

Thank you :slight_smile:

ah sorry! understood…hopefully you find a solution :+1:

I would rather create a new user (e.g. backupUser), move backup folder ownership to him (share back with your current user if it is needed) and set more limited Disk Quota for him. That’s it! Trash-bin will be cleaned up with corresponding rules, no mess with local data anymore.

P.S. how did you achieve it?

For me it dose not work:

Hi gas85,

my retention policy is 180,180 because I would like to guarantee my users to have their deleted data for 180 days. Then I need to change this and “hope” that nextcloud will not delete anything before the 180 days.
For me, the second user idea could work, but I also have some very non-technical users, for them, I would like to keep the setup as simple as possible.
My preference would be to manage this via any kind of admin settings.

@gas85 regarding your signal backup. I’m using the App FolderSync for all synchronization with the mobile phone. It is very reliable and working well for years now. Also, with thousands of files I never had issues.
So, my process is: 1. Signal backups to a local folder 2. Foldersync will sync that folder with nextcloud (one way).
Let me know if you need help with this :slight_smile:

1 Like

Have bad news for you…

There are edge cases...

Versioning ignores versions_retention_obligation `D, auto` · Issue #19791 · nextcloud/server · GitHub
Trash-bin ignores trashbin_retention_obligation · Issue #10862 · nextcloud/server · GitHub

But you will do retention not based on versions and trash-bin.

Well, hope this will get fixed :smiley:

@gas85

You think it could be a solution to setup a cron job that deletes the unwanted files in the file system from the files_trashbin folder and then run “occ files:scan --all”.

But to be honest, I don’t like messing around with these Nextcloud internal things.

I would rather write a script that will do this cleanup via e.g. API calls, but you need solution for many users on one system…

Also maybe there is a way to mark deleted files as expired via SQL. Not sure here.

In the meanwhile, a found a solution. I created a PHP script which calls the parts of the Nextcloud code, that is deleted a file from the tashbin. So it is like the users are doing it their own, no need to modify the database.

1 Like

Would you mind sharing the script? Encountering a similar issue and it would be great to have some reference material for a solution :slight_smile: I assume you are running it as a cron job or something?