The Storage component manages Viserons database and how to store files.
It helps you to organize segments, recordings and snapshots across multiple storage locations.
Files can be retained based on age and/or space used so that you never run out of storage.
Configuration
Configuration example
storage:
recorder:
tiers:
- path: /ssd/tier1
events:
max_age:
days: 1
continuous:
max_age:
days: 1
- path: /hdd/tier2
events:
max_age:
days: 7
snapshots:
tiers:
- path: /config/tier1
max_age:
days: 1
The above example will store recordings/events on /ssd/tier1
for 1 day, and then move them to /hdd/tier2
for 7 days.
It will also store continuous recordings on /ssd/tier1
for 1 day, after which they are deleted.
Configuration for recordings.
Tiers are used to move files between different storage locations. When a file reaches the max age or max size of a tier, it will be moved to the next tier. If the file is already in the last tier, it will be deleted.
Path to store files in. Cannot be /tmp
or /tmp/viseron
.
Poll the file system for new files. Much slower than non-polling but required for some file systems like NTFS mounts.
Move/delete files to the next tier when Viseron shuts down. Useful to not lose files when shutting down Viseron if using a RAM disk.
How often to check for files to move to the next tier.
Days between checks for files to move/delete.
Hours between checks for files to move/delete.
Minutes between checks for files to move/delete.
Seconds between checks for files to move/delete.
Retention rules for continuous recordings.
Minimum size of files to keep in this tier.
Min size in GB. Added together with min_mb
.
Min size in MB. Added together with min_gb
.
Maximum size of files to keep in this tier.
Max size in GB. Added together with max_mb
.
Max size in MB. Added together with max_gb
.
Maximum age of files to keep in this tier.
Minimum age of files to keep in this tier.
Retention rules for event recordings.
Minimum size of files to keep in this tier.
Min size in GB. Added together with min_mb
.
Min size in MB. Added together with min_gb
.
Maximum size of files to keep in this tier.
Max size in GB. Added together with max_mb
.
Max size in MB. Added together with max_gb
.
Maximum age of files to keep in this tier.
Minimum age of files to keep in this tier.
Snapshots are images taken when events are triggered or post processors finds anything. Snapshots will be taken for object detection, motiond detection, and any post processor that scans the image, for example face and license plate recognition.
Default tiers for all domains, unless overridden in the domain configuration.
Tiers are used to move files between different storage locations. When a file reaches the max age or max size of a tier, it will be moved to the next tier. If the file is already in the last tier, it will be deleted.
Minimum size of files to keep in this tier.
Min size in GB. Added together with min_mb
.
Min size in MB. Added together with min_gb
.
Maximum size of files to keep in this tier.
Max size in GB. Added together with max_mb
.
Max size in MB. Added together with max_gb
.
Maximum age of files to keep in this tier.
Minimum age of files to keep in this tier.
Path to store files in. Cannot be /tmp
or /tmp/viseron
.
Poll the file system for new files. Much slower than non-polling but required for some file systems like NTFS mounts.
Move/delete files to the next tier when Viseron shuts down. Useful to not lose files when shutting down Viseron if using a RAM disk.
How often to check for files to move to the next tier.
Days between checks for files to move/delete.
Hours between checks for files to move/delete.
Minutes between checks for files to move/delete.
Seconds between checks for files to move/delete.
Override the default snapshot tiers for face recognition. If not set, the default tiers will be used.
Tiers are used to move files between different storage locations. When a file reaches the max age or max size of a tier, it will be moved to the next tier. If the file is already in the last tier, it will be deleted.
Minimum size of files to keep in this tier.
Min size in GB. Added together with min_mb
.
Min size in MB. Added together with min_gb
.
Maximum size of files to keep in this tier.
Max size in GB. Added together with max_mb
.
Max size in MB. Added together with max_gb
.
Maximum age of files to keep in this tier.
Minimum age of files to keep in this tier.
Path to store files in. Cannot be /tmp
or /tmp/viseron
.
Poll the file system for new files. Much slower than non-polling but required for some file systems like NTFS mounts.
Move/delete files to the next tier when Viseron shuts down. Useful to not lose files when shutting down Viseron if using a RAM disk.
How often to check for files to move to the next tier.
Days between checks for files to move/delete.
Hours between checks for files to move/delete.
Minutes between checks for files to move/delete.
Seconds between checks for files to move/delete.
Override the default snapshot tiers for object detection. If not set, the default tiers will be used.
Tiers are used to move files between different storage locations. When a file reaches the max age or max size of a tier, it will be moved to the next tier. If the file is already in the last tier, it will be deleted.
Minimum size of files to keep in this tier.
Min size in GB. Added together with min_mb
.
Min size in MB. Added together with min_gb
.
Maximum size of files to keep in this tier.
Max size in GB. Added together with max_mb
.
Max size in MB. Added together with max_gb
.
Maximum age of files to keep in this tier.
Minimum age of files to keep in this tier.
Path to store files in. Cannot be /tmp
or /tmp/viseron
.
Poll the file system for new files. Much slower than non-polling but required for some file systems like NTFS mounts.
Move/delete files to the next tier when Viseron shuts down. Useful to not lose files when shutting down Viseron if using a RAM disk.
How often to check for files to move to the next tier.
Days between checks for files to move/delete.
Hours between checks for files to move/delete.
Minutes between checks for files to move/delete.
Seconds between checks for files to move/delete.
Override the default snapshot tiers for license plate recognition. If not set, the default tiers will be used.
Tiers are used to move files between different storage locations. When a file reaches the max age or max size of a tier, it will be moved to the next tier. If the file is already in the last tier, it will be deleted.
Minimum size of files to keep in this tier.
Min size in GB. Added together with min_mb
.
Min size in MB. Added together with min_gb
.
Maximum size of files to keep in this tier.
Max size in GB. Added together with max_mb
.
Max size in MB. Added together with max_gb
.
Maximum age of files to keep in this tier.
Minimum age of files to keep in this tier.
Path to store files in. Cannot be /tmp
or /tmp/viseron
.
Poll the file system for new files. Much slower than non-polling but required for some file systems like NTFS mounts.
Move/delete files to the next tier when Viseron shuts down. Useful to not lose files when shutting down Viseron if using a RAM disk.
How often to check for files to move to the next tier.
Days between checks for files to move/delete.
Hours between checks for files to move/delete.
Minutes between checks for files to move/delete.
Seconds between checks for files to move/delete.
Override the default snapshot tiers for motion detection. If not set, the default tiers will be used.
Tiers are used to move files between different storage locations. When a file reaches the max age or max size of a tier, it will be moved to the next tier. If the file is already in the last tier, it will be deleted.
Minimum size of files to keep in this tier.
Min size in GB. Added together with min_mb
.
Min size in MB. Added together with min_gb
.
Maximum size of files to keep in this tier.
Max size in GB. Added together with max_mb
.
Max size in MB. Added together with max_gb
.
Maximum age of files to keep in this tier.
Minimum age of files to keep in this tier.
Path to store files in. Cannot be /tmp
or /tmp/viseron
.
Poll the file system for new files. Much slower than non-polling but required for some file systems like NTFS mounts.
Move/delete files to the next tier when Viseron shuts down. Useful to not lose files when shutting down Viseron if using a RAM disk.
How often to check for files to move to the next tier.
Days between checks for files to move/delete.
Hours between checks for files to move/delete.
Minutes between checks for files to move/delete.
Seconds between checks for files to move/delete.
Be aware that the age of a file is calculated from the time it was created, not the time it was moved to the current tier.
It is NOT additive. In the Configuration example
above, a file will be completely deleted after 7 days, not 8 days.
Tiers
Tiers is list of directories that Viseron can use to store files.
Viseron will always write to the first tier. max_size
/max_age
then decides when files are moved to the next tier or deleted.
It is of utmost importance that the first tier is a local disk or a RAM disk.
Viseron will not be able to detect new files and will not be able to gather file metadata if the first tier is a network share/NTFS mount.
The first tier cannot be a network share/NTFS mount. Viseron will not be able to detect new files and will not be able to gather file metadata.
The first tier should be a local disk or a RAM disk. The other tiers can be network shares/NTFS mounts.
When the max_size
is hit the oldest files will be moved to the next tier.
When the age of a file exceeds the max_age
, it will be moved to the next tier.
If the current tier is the last one, the file is deleted instead.
If you change a tier path, you need to manually move the files to the new path.
For technical reasons it is very likely that there will be a few extra megabytes of files than the max_size
allows, so leave some extra space on the disk.
Continuous (24/7) recordings
To enable continuous recordings for all cameras you use the continuous
configuration option for a tier.
The below example will store 10gb of continuous recordings in the default location /segments
.
No events will be stored.
Continuous recordings configuration example
/config/config.yaml
storage:
recorder:
tiers:
- path: /
continuous:
max_size:
gb: 10
To set camera specific options, you can use continuous
or override the entire storage
configuration under your camera configuration.
See the recorder
documentation for the component that provides your cameras.
FFmpeg
GStreamer
Advanced configuration
For more advanced setups, min_size
and min_age
can be used.
They are best explained in a config.yaml
example:
Advanced configuration example
/config/config.yaml
storage:
recorder:
tiers:
- path: /mnt/ramdisk
move_on_shutdown: true
continuous:
max_size:
gb: 1
max_age:
days: 1
events:
max_size:
gb: 1
max_age:
days: 1
- path: /mnt/ssd
events:
min_size:
gb: 1
max_size:
gb: 10
max_age:
days: 7
- path: /mnt/nas
events:
min_age:
days: 30
max_size:
gb: 100
The same strategy can be applied for snapshots (images of detected objects, faces etc)
Database Migrations
Viseron will sometimes require database migrations to be run when you upgrade Viseron.
This is done automatically on startup, and you should avoid stopping Viseron while migrations are running.
Troubleshooting
To enable debug logging for
storage
, add the following to your
config.yaml
/config/config.yaml
logger:
logs:
viseron.components.storage: debug
sqlalchemy.engine: debug