Hi,
is there a way (command-line, midclt) to just trigger a cleanup of old snapshots according to a given lifetime?
A periodic snapshot task can be started directly via midctl, but to my knowledge always creates another snapshot with current timestamp. (And this timestamp even might not fit this task’s naming schema.)
I also would be fine with directly passing a lifetime unit, like 1 month / everything older than one month as argument to some CLI command.
@pmh Thanks very much, will have a look at it. I also considered Sanoid and Syncoid. But your mentioned alternative doesn’t have any dependencies, which seems better suited for TrueNAS appliance.
Ideally TrueNAS would provide features in a more concise manner natively. What I am questioning here, are some of the task principles:
Why am I able to start a task via midclt call pool.snapshottask.run, that is not able to match and auto-cleanup its own created snapshots according to lifetime? In other words: Task schedule should be independent from snapshot matching via naming schema for cleanups.
Task mixes actions a) snapshot auto-cleanup b) snapshot creation. It would be great to have a midclt method similar to
Hm, that zfs-prune-snapshots solution unfortunately does not help with replication of snapshots. I would loose integration between Periodic Snapshot Tasks and Replication Tasks in TrueNAS, so not optimal either.
Guess it’s all or nothing - either you leverage built-in solution and accept current shortcomings or step on the manual route (Sanoid etc.) with full flexibility, but harder ZFS learning curve and no GUI integration.
In the meanwhile, my feature request has evolved more clearly: Provide non-periodic snapshot tasks.
These are triggered manually, via Run job GUI button similar to Replication tasks or from an outer API client like midclt, and have no schedule.
Non-periodic task runs trigger auto-cleanup of old snapshots, but - unlike periodic tasks - just check on the snapshot naming schema (not task schedule).
Example: Task with naming schema auto-documents-%Y-%m-%d_%H-%M would include all snapshots starting with auto-documents-. %Y, %m, %d, %H and %M placeholders matter for calculating snapshot lifetime. In contrast, current periodic snapshot tasks also check if %Y, %m, %d, %H and %M match their task schedule - and this does not make sense, if task is triggered in ways mentioned above.
I think, these kind of tasks would be a great addition in combination with the new TrueNAS API client/midclt.
Do developers have something like this (or task refactoring in general) already on their roadmap?