Retention Policies & Automated Storage Cleanup
RUSEON Core features an automated background retention scheduler (internal/recorder/) that continuously monitors disk utilization, enforces data retention policies, and prevents storage exhaustion.
Retention Strategies
RUSEON Core supports two complementary retention triggers configured in config.yaml:
1. Time-Based Retention (retention_days)
- Enforces maximum storage duration per camera or globally.
- Recordings older than
retention_days(calculated from directory date and file epoch) are deleted on the next retention cycle. - Example: Setting
retention_days: 30guarantees recordings beyond 30 days are automatically purged.
2. Capacity-Based Quota (min_disk_free_gb / max_disk_usage_percent)
- Prevents storage volumes from reaching 100% capacity, which would freeze database writes or crash the OS.
- If free disk space drops below
min_disk_free_gb(e.g. 20 GB) or usage exceedsmax_disk_usage_percent(e.g. 90%), the retention engine immediately triggers emergency FIFO pruning, deleting the oldest hourly recording directories until target free space is restored.
The Pruning Algorithm
- Chronological Traversal (FIFO): The cleaner navigates the Storage File Layout starting from the oldest
{YYYY}/{MM}/{DD}/{HH}directory. - Atomic Deletion: Deletes both the
.mp4video container and the accompanying.idxsidecar file. - Empty Folder Pruning: Automatically removes emptied hour, day, and month directories to keep the filesystem clean.
- Database Sync: Removes deleted file records from the BadgerDB index so the REST API and UI timeline update immediately.
- Prometheus Metrics: Emits
ruseon_retention_deleted_bytes_totalandruseon_retention_deleted_files_total.
Configuration Reference
yaml
recording:
enabled: true
storage_path: "/data/recordings"
# Time retention limit in days (0 = unlimited, bounded only by disk space)
retention_days: 14
# Emergency disk space safety thresholds
min_disk_free_gb: 25
max_disk_usage_percent: 90
# Frequency of the cleanup cycle
cleanup_interval: "10m"