Expose native storage retention for VM and CT backups

This commit is contained in:
Jonatan
2026-10-16 20:32:05 +02:00
parent 3000c1cd66
commit 113659c0e3
11 changed files with 353 additions and 22 deletions
+18
View File
@@ -0,0 +1,18 @@
// Native Proxmox retention properties, shared by storage and job editors.
export const RETENTION = ["last", "hourly", "daily", "weekly", "monthly", "yearly"] as const
export function parseRetention(prune: string) {
const fields: Record<string, string> = {}
let keepAll = false
for (const part of prune.split(",")) {
const [key, value] = part.trim().split("=")
if (key === "keep-all") keepAll = value === "1"
else if (key?.startsWith("keep-") && Number(value) > 0) fields[key.slice(5)] = String(Number(value))
}
return { fields, keepAll }
}
export function buildRetention(fields: Record<string, string>, keepAll: boolean) {
const parts = RETENTION.filter(key => Number(fields[key]) > 0).map(key => `keep-${key}=${Number(fields[key])}`)
return parts.length ? parts.join(",") : keepAll ? "keep-all=1" : ""
}