Skip to content

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):

bash
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 ​

  1. Go to System Settings β†’ Advanced β†’ Cron Jobs β†’ Add

  2. Fill in:

    • Description: Delete old camera recordings

    • User: root (so it can delete all dirs)

    • Command:

      bash
      find /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 * * *
    • Enabled: βœ…

  3. Save.

πŸ”Ή Step 4: Test before enabling delete ​

Run once in "dry-run" mode:

bash
find /mnt/PoolName/CamRecordings/Reolink/ -type d -mtime +7 -print

This 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”.

Version: dca0e30 | Updated: 2026-10-28