Automated storage cleanup β
House security cameras will flood the dataset fast. With TrueNAS SCALE, you can automate cleanup so you never run out of space.
Since your cameras create a structure like:
/mnt/PoolName/CamRecordings/Reolink/YYYY/MM/DDβ¦the best method is a Periodic Task (Cron Job) that deletes files/folders older than a set number of days.
πΉ Step 1: Decide retention β
Letβs say you want to keep 7 days of recordings. That means:
- Anything older than 7 days β auto-delete.
- New data always has space.
You can adjust (e.g. 14 or 30 days) depending on your disk size.
πΉ Step 2: Create a script β
Weβll use the find command, which is perfect for this. Example command (delete files older than 7 days):
find /mnt/PoolName/CamRecordings/Reolink/ -type d -mtime +7 -exec rm -rf {} +Explanation:
-type dβ match directories-mtime +7β modified more than 7 days ago-exec rm -rf {} +β delete them
β οΈ Careful with this β it will permanently delete old dirs. Test with -print first instead of -exec rm -rf to see what would be deleted.
πΉ Step 3: Add as a Cron Job in SCALE β
Go to System Settings β Advanced β Cron Jobs β Add
Fill in:
Description:
Delete old camera recordingsUser:
root(so it can delete all dirs)Command:
bashfind /mnt/PoolName/CamRecordings/Reolink/ -type d -mtime +7 -exec rm -rf {} +Schedule: e.g. daily at 03:00 (when cameras record less).
- Cron format:
0 3 * * *
- Cron format:
Enabled: β
Save.
πΉ Step 4: Test before enabling delete β
Run once in "dry-run" mode:
find /mnt/PoolName/CamRecordings/Reolink/ -type d -mtime +7 -printThis just lists what would be deleted. If it looks correct β enable the real job.
πΉ Step 5: Optional β Use Quota as Backup Safety β
Since you already allocated 1 TiB for this dataset, you can set a dataset quota:
- Go to Storage β Datasets β CamRecordings β Edit Options
- Set Quota = 1 TiB.
This ensures camera data wonβt overflow into your other datasets.
β With this setup:
- Dataset is capped at 1 TiB.
- Files older than X days get purged nightly.
- Cameras never stop recording due to βdisk fullβ.