Recycle Bin
This tutorial shows how to configure a Recycle Bin, where files are copied to a separate folder before being overwritten or deleted. An automatic retention policy cleans up the recycle folder periodically.
This approach uses two rules:
- A pre-upload / pre-delete rule that copies the file to
/recyclebefore the operation proceeds. - A scheduled rule that cleans up files older than a configurable threshold from
/recycle.
Step 1: Create a Copy to Recycle Action
From the WebAdmin, expand the Event Manager section, select Actions and add a new action.
Create an action named copy to recycle, set the type to Filesystem, and choose Copy as the filesystem action.
Add a copy entry:
- Source:
/{{.VirtualPath}} - Target:
/recycle/{{.VirtualPath}}_{{.UID}}
The {{.UID}} placeholder appends a unique event identifier to the filename, ensuring that multiple versions of the same file do not overwrite each other in the recycle folder. For example, deleting /reports/q1.csv produces a recycle copy named /recycle/reports/q1.csv_<unique-id>.
Step 2: Create a Pre-Upload / Pre-Delete Rule
Now select Rules and create a rule named copy_to_recycle.
- Trigger: Filesystem events
- Events:
pre-upload,pre-delete
The rule triggers before the upload or delete operation, so the current version of the file is still available to be copied.
Conditions
Add a path filter to exclude the recycle folder itself — otherwise, deleting files from the recycle folder would trigger another copy, creating an infinite loop. In Path filters, add:
- the pattern
/recycle/**; - Mode: Inverse match.
This means "match all paths except those under /recycle/".
Set a minimum file size filter to 1 byte. This serves two purposes: it skips empty files on delete, and — more importantly — it detects overwrites on pre-upload. When a user uploads a file that already exists, the pre-upload event fires with the size of the existing file. A minimum size of 1 ensures the rule only triggers when there is an existing file to preserve (size > 0), so new uploads to a path that doesn't exist yet are not affected.
Actions
Select the copy to recycle action and enable Synchronous execution.
Synchronous execution is required. The copy must complete before the upload or delete operation proceeds. Without "Synchronous execution", the original file might be overwritten or deleted before the copy finishes.
Step 3: Create a Retention Policy for the Recycle Folder
To prevent the recycle folder from growing indefinitely, create a scheduled rule that automatically deletes old files.
Create a Retention Action
Create a new action named recycle retention, set the type to Data retention check.
Add a retention policy:
| Path | Retention (hours) | Delete empty dirs |
|---|---|---|
/recycle |
72 | Yes |
This deletes files older than 72 hours (3 days) from the /recycle folder and removes any empty subdirectories left behind. The age of a file is read from its modification time, see Note on File Modification Time.
Create a Scheduled Rule
Create a rule named recycle_retention:
- Trigger: Schedules
- Schedule: Daily at 01:00 UTC (hour
1, day of week*) - Actions:
recycle retention
How It Works in Practice
- A user deletes
/reports/q1.csv. - The
pre-deleterule fires and synchronously copies the file to/recycle/reports/q1.csv_<unique-id>. - The delete operation proceeds —
/reports/q1.csvis removed. - The file remains in
/recyclefor 72 hours. - The nightly retention job cleans up files older than 72 hours.
The same flow applies to uploads that overwrite existing files — the pre-upload trigger saves the current version before it is replaced. The pre-delete trigger also saves the existing file when a rename or a copy overwrites it, and when an SFTP truncate request makes it smaller.
Quota
The copies in
/recycle count toward the user's quota. When the quota is full the copy fails, and the delete or overwrite that triggered it is refused too. A user with a full quota therefore cannot free space by deleting files until the retention empties the bin. To keep the bin out of the user's quota, mount /recycle as a virtual folder with Quota size and Quota files set to 0. On a group, a single folder mapping with sub-path /%username% gives each member a bin of its own.
Read-Only Recycle Bin
To let users browse the bin and restore files while every deleted file stays in it until the retention runs, add a per-directory permission on /recycle with list, download and copy:
- a file is restored by downloading it and uploading it again, or with Copy in the WebClient; the original stays in the bin;
- deleting, renaming, uploading and changing attributes inside
/recycleare refused.
The copy to recycle action and the retention keep working, since actions run with full permissions. Leave out rename, which moves a file out of the bin, and chtimes, which changes the modification time the retention reads.



