Nextcloud Snap: trashbin_retention_obligation doesn't work/apply

I’ve Nextcloud running as Snap package on Ubuntu 22.04 LTS. While setting up backup I found that there are lots of deleted files and folders older than 1 year which I don’t want to retain and don’t want to backup. So I read the docs and the forum and found that I can set

trashbin_retention_obligation

to let Nextcloud remove those files and folders after a certain while.

So I set the parameters as the docs explain:

sudo nextcloud.occ config:app:set files_trashbin trashbin_retention_obligation --value='90, 120'

which should “keep files and folders in the trash bin for at least 90 days and delete when exceeds 120 days (note: files will not be deleted automatically if space is needed)

Of course I’ve checked the parameter afterwards:

sudo nextcloud.occ config:app:get files_trashbin trashbin_retention_obligation
90, 120

I waited for the next Cron run and… all deleted files are still there.

I tried multiple other values but… all deleted files are still there.

Then I ran (which should, according to the docs, “expire versions”)

sudo nextcloud.occ trashbin:expire

which told me:

Auto expiration is configured - keeps files and folders in the trash bin for 30 days and automatically deletes anytime after that if space is needed (note: files may not be deleted if space is not needed)

It looks like my configuration is not taken into account.

In the docs I’ve also found a command to “Activate background job” and ran it:

sudo nextcloud.occ config:app:delete files_trashbin background_job_expire_trash

which told me:

Config value background_job_expire_trash of app files_trashbin deleted

This doesn’t sound to me like something has been activated, it sounds like it has deleted the background job!?

I’ve also set the last_run property in the MySQL database table oc_jobs as described in another thread without success.

I’ve read countless threads in this forum and it looks like this is not only a mystery for me and it also keeps causing headaches to a others during the last years.

I’m glad for everyone who can help to shed a light on this!

Cheers,
SiKr

maybe this helps Trash bin retention doesn't have effect

also note, there is a difference between trashbin and groupfolders:trashbin

personally i run a daily cron cleanup job:

  #!/bin/bash
## Nextcloud trash cleanup for user and groups
sudo nextcloud.occ trashbin:cleanup --all-users ;
sudo nextcloud.occ groupfolders:trashbin:cleanup -f 

exit
1 Like

@SiKr looking at this: Deleted Items (trash bin) — Nextcloud latest Administration Manual latest documentation

i’m thinking you might add a D to your number of days parameter to specify Days…

sudo nextcloud.occ config:app:set files_trashbin trashbin_retention_obligation --value='D90, D120'
1 Like

Hi scubamuc,

thank you for the help! :slightly_smiling_face:

First I’ve tried to user the D in the command:

sudo nextcloud.occ config:app:set files_trashbin trashbin_retention_obligation --value='D90, D120'

which told me:

Config value ‘trashbin_retention_obligation’ for app ‘files_trashbin’ is now set to ‘D90, D120’, stored as mixed in fast cache

But after the Cron run all deleted files are still there.

At next I ran the trashbin:expire command:

sudo nextcloud.occ trashbin:expire -vvv

which claimed:

Auto expiration is configured - keeps files and folders in the trash bin for 30 days and automatically deletes anytime after that if space is needed (note: files may not be deleted if space is not needed)

So NC is still ignoring my setting.

Then I ran trashbin:cleanup :

sudo nextcloud.occ trashbin:cleanup --all-users -vvv 

Remove deleted files for all users
Remove deleted files for users on backend Database
Deleting 13.2 GB in trash for …

So this finally deleted ALL files in the trashbin.

Still I’m not happy with it. I’d like to keep the deleted files for a while, otherwise I could simply remove the “Deleted Files” app (as far as I understand this is the app creating/managing the trashbin). Also I wonder why NC is permanently ignoring my settings. :face_with_raised_eyebrow:

Cheers,
SiKr

well at least tiny steps… :wink:

yeah, I understand and I agree. May I suggest creating an issue with the Nextcloud devs

I’m not sure that NC is ignoring your settings… maybe NC just doesn’t understand :grinning:. I’ve documented and tested plenty get and set commands in our Nextcloud snap wiki and plenty PHP configuration options and they all worked fine, except when the command was unknown or had a typo.

1 Like

Hi scubamuc,
thanks a lot for the link to the very decent Snap Nexcloud Wiki. I wasn’t aware of it. :smiling_face_with_three_hearts:

I still believe (at least a bit) that the problem is in front of the machine :grimacing: and will try a few more things before opening an issue for that.

Since I’ve now removed all the deleted files it’ll be hard to test the retention parameters. :laughing: But as the “files versions” app seems to use the same mechanics and very similar parameters I’ll try to figure out how to configure this properly with it. I’ll come back with my findings as soon as I’ve news.

Cheers,
SiKr

1 Like

The trashbin_retention_obligation is a config.php / system config entry, not an app setting for files_trashbin. You can either set it in your config.php directly or using:

occ config:system:set trashbin_retention_obligation --value="90, 120"

(or equivalent, adapted to the Snap).

I can see why it may be mistaken for that, but what this is doing is dropping the “no” value described just above in the docs for deactivating the background job.

Removing the value is effectively the same as switching the “no” to a “yes” since it’s the default.

2 Likes

ahh… @jtr is a magician thanks for that :ok_hand:

@SiKr so NC is not ignoring your settings after all :sunglasses:

sudo nextcloud.occ config:system:set trashbin_retention_obligation --value="90, 120"

i’ve gone ahead and added lessons learned to our wiki thanks to @SiKr and @jtr

1 Like

Hi @jtr & @scubamuc,

I can confirm that what @jtr wrote does the trick. I’ve verified that on another instance and deleted files got removed as expected.

I’ve also verified that the other command effectively enables the job as @jtr wrote and not deleted it as I suspected.

Thank you both for the help and for updating the Wiki. :blush:

Cheers,
SiKr

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.