Understanding and Fixing Nextcloud Trash Retention Issues

 

Many administrators assume deleted files in Nextcloud disappear automatically after 30 days. In practice, this often isn’t true. If your server has plenty of free disk space, items in the trash may remain indefinitely, causing bloated backups, wasted storage, or slow sync operations.

This guide explains why this happens, where the default logic comes from, and how you can adjust retention to ensure your trash clears automatically.

The Core Problem

Nextcloud keeps deleted files in the Trashbin and will only remove them when:

  • The minimum retention time has passed
  • Storage availability becomes low

This means that if you run Nextcloud on a server with large unused capacity, cleanup may never trigger.

Nextcloud’s documented default behaviour states that deleted files are kept for at least 30 days and are removed only when free space is required, which may cause indefinite retention on systems with large storage volumes.

Why It Happens

The logic is designed to protect users from accidental data loss. However, this design assumes most environments operate under normal storage pressure. Modern installations often run on disks where free space is abundant — and the automatic cleanup logic never activates.

How to Fix It

You can override this behaviour using the trashbin_retention_obligation parameter in config.php.

Retention Modes Explained

auto

  • Default Nextcloud behaviour
  • Retain for a minimum of 30 days
  • Delete only when storage pressure exists

D, auto

  • Keep for D days minimum
  • After that, rely on automatic behaviour

auto, D

  • Keep for up to D days maximum
  • Can be deleted earlier if disk space becomes tight

D1, D2

  • Keep at least D1 days
  • Force deletion no later than D2 days

disabled

  • Never delete anything automatically

The trashbin_retention_obligation configuration setting defines how long deleted items remain in Trashbin, allowing administrators to enforce mandatory deletion windows or maximum retention limits.

How to Configure Automatic Deletion

Follow these steps to enforce predictable trash removal.

Step 1 — Locate Your config.php

Common location:

/var/www/nextcloud/config/config.php

Step 2 — Open the File

Example with nano:

sudo nano /var/www/nextcloud/config/config.php

Step 3 — Add Your Preferred Retention Rule

Option A — Automatically delete after 30 days

(Allows earlier deletion if the disk becomes full.)

'trashbin_retention_obligation' => 'auto, 30',

Option B — Keep for 30 days but delete no later than 35 days

'trashbin_retention_obligation' => '30, 35',

Option C — Disable automatic deletion

'trashbin_retention_obligation' => 'disabled',

Adjust the number of days to meet your organisation’s retention requirements.

Step 4 — Save and Exit

If using nano:

  • CTRL + O → save
  • Enter
  • CTRL + X → exit

Summary

For most installations, setting auto, 30 ensures deleted files disappear after 30 days while still allowing earlier cleanup if storage ever becomes constrained.

This avoids trash hoarding, reduces backup load, and keeps your Nextcloud instance running efficiently.

Further thoughts…

If you store large media, run multi-user environments, or back up your entire data directory, your trash policy matters more than you might expect. Documenting your retention settings helps staff understand deletion expectations and prevents confusion about “missing” files later.