How to force automatic removal of deleted files in nextcloud

Nextcloud will get rid of files that have been deleted for 30 days. However in reality these files will remain on the server until such a time that physical storage is running low. In other words they deleted items don’t actually get deleted until necessary!

In the third installment of optimizing nextcloud performance, we will tweak the default settings for automatically deleting files.

Configuration parameters

Config parameters exist to allow nextcloud server owners the capability of adapting this behavior, these are as follows:

  • auto – standard behavior
  • D, auto – change the minimum days a file is kept with standard behavior
  • auto, D – delete after a number of days, but earlier if space is required
  • D1, D2 – do not delete before, but definitely delete after a certain number of days
  • disabled – disable automatic deletion

Example rules

To automatically delete files after 30 days, and give nextcloud the ability to delete sooner if space does eventually run low, you can add this to your config.php file located at /var/www/html/nextcloud/config/config.php you would add the following:

'trashbin_retention_obligation' => 'auto, 30',

To ensure all files are retained for 30 days, but definitely deleted after 35 days, the following can be added to your config.php:

'trashbin_retention_obligation' => '30, 35',