agent v0.51.0: local vzdump retention default (--prune-backups keep-last=3)

The preventive counterpart to host_disk + storage_fill detectors: the periodic local
whole-guest vzdump now prunes its own old archives (keep-last=3, clamped >=1) so a box
can't refill its own root via its own backups. Local target only — PBS never pruned
(resolved via ListStorage; fail-safe skip on unknown). Seeded in host-install.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxLA1mZurFq9kt8hneFeCs
This commit is contained in:
2026-06-30 19:44:07 +02:00
parent 79eb0a8486
commit 06e0bc9c25
8 changed files with 212 additions and 16 deletions
+8
View File
@@ -74,6 +74,10 @@ type VzdumpOptions struct {
// Notes is the PVE `notes-template` for the backup (a template string PVE expands,
// e.g. with {{guestname}}/{{node}}). Optional.
Notes string
// PruneBackups is the PVE `--prune-backups` retention spec applied AFTER this backup, e.g.
// "keep-last=3". PVE prunes only THIS vmid's archives on THIS storage (the vzdump is vmid+storage
// scoped), so it never touches other guests/storages or PBS. Empty → no prune (legacy behaviour).
PruneBackups string
}
// Vzdump starts a backup via POST /nodes/{node}/vzdump. Returns the UPID. An
@@ -94,6 +98,10 @@ func (c *Client) Vzdump(ctx context.Context, opts VzdumpOptions) (string, error)
if opts.Notes != "" {
v.Set("notes-template", opts.Notes) // PVE 9.x param name (verified on demo)
}
if opts.PruneBackups != "" {
// Per-run retention: PVE prunes older archives of THIS vmid on THIS storage after the backup.
v.Set("prune-backups", opts.PruneBackups)
}
return c.dataString(ctx, http.MethodPost, "/nodes/"+c.node+"/vzdump", v)
}