Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Stop showing an in-flight backup as a completed one
rcourtmancb12b6f35c84
diff --git a/frontend-modern/src/components/Workloads/GuestRow.tsx b/frontend-modern/src/components/Workloads/GuestRow.tsxindex c4c75fd062..e58d0e0af2 100644--- a/frontend-modern/src/components/Workloads/GuestRow.tsx+++ b/frontend-modern/src/components/Workloads/GuestRow.tsx@@ -242,6 +242,7 @@ export function GuestRow(props: GuestRowProps) {<BackupIndicatorlastBackup={props.guest.lastBackup}isTemplate={props.guest.template}+ backupRunning={props.guest.backupInProgress}/></Show><Show when={nestedWorkloadCueLabel()}>@@ -667,7 +668,10 @@ export function GuestRow(props: GuestRowProps) {}><Show when={!props.guest.template}>- <BackupStatusCell lastBackup={props.guest.lastBackup} />+ <BackupStatusCell+ lastBackup={props.guest.lastBackup}+ backupRunning={props.guest.backupInProgress}+ /></Show><Show when={props.guest.template}><span class="text-xs text-slate-400" aria-hidden="true">diff --git a/frontend-modern/src/components/Workloads/GuestRowCells.tsx b/frontend-modern/src/components/Workloads/GuestRowCells.tsxindex ac9c21e88c..91232edaee 100644--- a/frontend-modern/src/components/Workloads/GuestRowCells.tsx+++ b/frontend-modern/src/components/Workloads/GuestRowCells.tsx@@ -10,11 +10,13 @@ import {getWorkloadsGuestBackupStatusPresentation,getWorkloadsGuestBackupTooltip,getWorkloadsGuestNetworkEmptyState,+ type WorkloadsGuestBackupDisplayStatus,} from '@/utils/workloadGuestPresentation';function BackupIndicator(props: {lastBackup: string | number | null | undefined;isTemplate: boolean;+ backupRunning?: boolean;}) {if (props.isTemplate) return null;@@ -24,6 +26,9 @@ function BackupIndicator(props: {);const config = createMemo(() => getWorkloadsGuestBackupStatusPresentation(backupInfo().status));+ // The indicator flags a problem (no fresh completed backup) and stays+ // truthful while a backup is running - only a COMPLETED backup clears it.+ // The running state is surfaced in the tooltip and the Backup column badge.const shouldShow = createMemo(() => {const status = backupInfo().status;return status === 'stale' || status === 'overdue' || status === 'never';@@ -31,7 +36,7 @@ function BackupIndicator(props: {const tooltipText = createMemo(() => {const info = backupInfo();- return getWorkloadsGuestBackupTooltip(info.status, info.ageFormatted);+ return getWorkloadsGuestBackupTooltip(info.status, info.ageFormatted, props.backupRunning);});return (@@ -85,7 +90,7 @@ function getBackupAgeBadgeLabel(return compact.replace(/\s+ago$/, '');}-function getBackupAgeBadgeClass(status: BackupInfo['status']): string {+function getBackupAgeBadgeClass(status: WorkloadsGuestBackupDisplayStatus): string {const layout ='inline-flex h-5 min-w-[3.25rem] items-center justify-center gap-1 px-1.5 text-[10px] font-semibold leading-none tabular-nums cursor-help';// A healthy backup only needs its shield. Existing backups that cross an age@@ -103,6 +108,11 @@ function getBackupAgeBadgeClass(status: BackupInfo['status']): string {return `${pill} border-yellow-200 bg-yellow-50 text-yellow-700 dark:border-yellow-900/70 dark:bg-yellow-950/40 dark:text-yellow-300`;case 'never':return `${pill} border-red-200 bg-red-50 text-red-700 dark:border-red-900/70 dark:bg-red-950/40 dark:text-red-300`;+ // A running backup is work underway, not success (green would claim a+ // completed backup) and not absence (hiding it would look like nothing+ // is happening). Blue matches the Backups page's running-task tone.+ case 'running':+ return `${pill} border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-900/70 dark:bg-blue-950/40 dark:text-blue-300`;}}@@ -307,17 +317,35 @@ function OSInfoCell(props: { osName: string; osVersion: string; agentVersion: st);}-function BackupStatusCell(props: { lastBackup: string | number | null | undefined }) {+function BackupStatusCell(props: {+ lastBackup: string | number | null | undefined;+ backupRunning?: boolean;+}) {const tip = useTooltip();const alertsActivation = useAlertsActivation();const info = createMemo(() =>getBackupInfo(props.lastBackup, alertsActivation.getBackupThresholds()),);- const config = createMemo(() => getWorkloadsGuestBackupStatusPresentation(info().status));- const badgeLabel = createMemo(() => getBackupAgeBadgeLabel(props.lastBackup, info()));+ // The badge shows "running" while a backup is underway: green would claim+ // a completed backup that does not exist yet, and the age states would+ // hide that the situation is being remediated. The age itself still+ // reflects the latest COMPLETED backup and is kept in the tooltip.+ const displayStatus = createMemo<WorkloadsGuestBackupDisplayStatus>(() =>+ props.backupRunning ? 'running' : info().status,+ );+ const config = createMemo(() => getWorkloadsGuestBackupStatusPresentation(displayStatus()));+ const badgeLabel = createMemo(() =>+ displayStatus() === 'running' ? 'Running' : getBackupAgeBadgeLabel(props.lastBackup, info()),+ );+ const hasCompletedBackup = createMemo(() => info().status !== 'never');const ariaLabel = createMemo(() => {const currentInfo = info();+ if (props.backupRunning) {+ return hasCompletedBackup()+ ? `Backup status: backup running now, last completed backup ${currentInfo.ageFormatted}`+ : 'Backup status: backup running now, no completed backup yet';+ }if (currentInfo.status === 'never') return 'Backup status: no backup found';return `Backup status: ${currentInfo.status}, last backup ${currentInfo.ageFormatted}`;});@@ -325,13 +353,14 @@ function BackupStatusCell(props: { lastBackup: string | number | null | undefinereturn (<><span- class={getBackupAgeBadgeClass(info().status)}+ class={getBackupAgeBadgeClass(displayStatus())}onMouseEnter={tip.onMouseEnter}onMouseLeave={tip.onMouseLeave}aria-label={ariaLabel()}><svgclass="h-3.5 w-3.5 flex-shrink-0"+ classList={{ 'animate-pulse': displayStatus() === 'running' }}viewBox="0 0 24 24"fill="none"stroke="currentColor"@@ -350,8 +379,11 @@ function BackupStatusCell(props: { lastBackup: string | number | null | undefine<Show when={config().icon === 'x'}><path d="M10 10l4 4M14 10l-4 4" /></Show>+ <Show when={config().icon === 'running'}>+ <path d="M8 12h.01M12 12h.01M16 12h.01" />+ </Show></svg>- <Show when={info().status !== 'fresh'}>+ <Show when={displayStatus() !== 'fresh'}><span>{badgeLabel()}</span></Show></span>@@ -361,9 +393,14 @@ function BackupStatusCell(props: { lastBackup: string | number | null | undefine<div class="font-medium mb-1 text-slate-300 border-b border-border pb-1">Backup Status</div>- <Show when={info().status !== 'never'}>+ <Show when={props.backupRunning}>+ <div class="py-0.5 text-blue-400">Backup running now…</div>+ </Show>+ <Show when={hasCompletedBackup()}><div class="py-0.5">- <div class="text-slate-400">Last backup</div>+ <div class="text-slate-400">+ {props.backupRunning ? 'Last completed backup' : 'Last backup'}+ </div><div class="text-base-content font-medium">{new Date(props.lastBackup!).toLocaleDateString(undefined, {weekday: 'short',@@ -375,11 +412,17 @@ function BackupStatusCell(props: { lastBackup: string | number | null | undefine<div class="text-slate-300">{new Date(props.lastBackup!).toLocaleTimeString()}</div></div><div class="pt-1 mt-1 border-t border-border">- <span class={config().color}>{info().ageFormatted}</span>+ <span class={getWorkloadsGuestBackupStatusPresentation(info().status).color}>+ {info().ageFormatted}+ </span></div></Show>- <Show when={info().status === 'never'}>- <div class="py-0.5 text-red-400">No backup has ever been recorded for this guest.</div>+ <Show when={!hasCompletedBackup()}>+ <div class="py-0.5 text-red-400">+ {props.backupRunning+ ? 'No completed backup yet - the first backup is running now.'+ : 'No backup has ever been recorded for this guest.'}+ </div></Show></div></TooltipPortal>diff --git a/frontend-modern/src/components/Workloads/__tests__/BackupStatusCell.test.tsx b/frontend-modern/src/components/Workloads/__tests__/BackupStatusCell.test.tsxindex e78d25bb1f..028de384f7 100644--- a/frontend-modern/src/components/Workloads/__tests__/BackupStatusCell.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/BackupStatusCell.test.tsx@@ -5,8 +5,10 @@ import { BackupStatusCell } from '../GuestRowCells';const HOUR_MS = 60 * 60 * 1000;-const renderCell = (lastBackup: string | number | null) => {- const { container } = render(() => <BackupStatusCell lastBackup={lastBackup} />);+const renderCell = (lastBackup: string | number | null, backupRunning?: boolean) => {+ const { container } = render(() => (+ <BackupStatusCell lastBackup={lastBackup} backupRunning={backupRunning} />+ ));const badge = container.querySelector('span[aria-label^="Backup status"]');if (!badge) throw new Error('backup badge not rendered');return badge as HTMLElement;@@ -60,4 +62,40 @@ describe('BackupStatusCell', () => {expect(badge.className).toContain('border-red-200');expect(badge.getAttribute('aria-label')).toBe('Backup status: no backup found');});++ // A backup that merely STARTED must never wear the green shield - the+ // repro was an in-flight PBS snapshot at 9% reading as a healthy backup+ //. Running is its own blue state, and the last COMPLETED age+ // stays available to assistive tech.+ it('shows a blue Running pill instead of the green shield while a backup runs', () => {+ const badge = renderCell(Date.now() - 2 * HOUR_MS, true);++ expect(badge.textContent?.trim()).toBe('Running');+ expect(badge.className).toContain('border-blue-200');+ expect(badge.className).not.toContain('text-green-600');+ expect(badge.getAttribute('aria-label')).toMatch(+ /^Backup status: backup running now, last completed backup /,+ );+ });++ it('shows Running rather than red None while a first backup runs', () => {+ const badge = renderCell(null, true);++ expect(badge.textContent?.trim()).toBe('Running');+ expect(badge.className).toContain('border-blue-200');+ expect(badge.className).not.toContain('border-red-200');+ expect(badge.getAttribute('aria-label')).toBe(+ 'Backup status: backup running now, no completed backup yet',+ );+ });++ it('keeps the completed-backup age when a stale guest starts backing up', () => {+ const badge = renderCell(Date.now() - 200 * HOUR_MS, true);++ // The badge shows Running, not the age - but the age must survive in+ // the accessible label so "running" never erases how old the last+ // completed backup is.+ expect(badge.textContent?.trim()).toBe('Running');+ expect(badge.getAttribute('aria-label')).toContain('last completed backup');+ });});diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts b/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.tsindex 6af08fd738..a252a13440 100644--- a/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts+++ b/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts@@ -45,6 +45,8 @@ export interface RecoverableArtifact {detail: string;protected: boolean;verified?: boolean;+ /** A still-running backup is writing this artifact; it is not recoverable yet. */+ running?: boolean;fileCount?: number;}@@ -490,7 +492,8 @@ export function buildProxmoxBackupRecoveryModel(location: `${backup.datastore || '—'} / ${backup.namespace?.trim() || '(root)'}`,detail: pbsBackupFileDetailLabel(backup.files.length),protected: backup.protected,- verified: backup.verified,+ verified: backup.inProgress ? undefined : backup.verified,+ running: backup.inProgress === true,fileCount: backup.files.length,});}@@ -515,7 +518,8 @@ export function buildProxmoxBackupRecoveryModel(location: archive.storage || archive.node || '—',detail: archive.volid || archive.format || archiveSource.detailFallbackLabel,protected: archive.protected,- verified: archive.isPBS ? archive.verified : undefined,+ verified: archive.inProgress ? undefined : archive.isPBS ? archive.verified : undefined,+ running: archive.inProgress === true,});}@@ -561,19 +565,23 @@ export function buildProxmoxBackupRecoveryModel(}for (const row of rows.values()) {+ // A running artifact cannot be restored from yet, so the "latest"+ // pointers (which answer "what can I recover to?") skip it. The artifact+ // itself stays listed with a Running state.+ const completed = row.artifacts.filter((artifact) => !artifact.running);row.latestPBS = newest(- row.artifacts.filter((artifact) => artifact.sourceKind === 'pbs'),+ completed.filter((artifact) => artifact.sourceKind === 'pbs'),(artifact) => artifact.createdMs,);row.latestArchive = newest(- row.artifacts.filter((artifact) => artifact.sourceKind === 'archive'),+ completed.filter((artifact) => artifact.sourceKind === 'archive'),(artifact) => artifact.createdMs,);row.latestSnapshot = newest(- row.artifacts.filter((artifact) => artifact.sourceKind === 'snapshot'),+ completed.filter((artifact) => artifact.sourceKind === 'snapshot'),(artifact) => artifact.createdMs,);- row.latestRecovery = newest(row.artifacts, (artifact) => artifact.createdMs);+ row.latestRecovery = newest(completed, (artifact) => artifact.createdMs);}const coverageRows = Array.from(rows.values()).map((row) => {@@ -670,6 +678,7 @@ export function recoverableArtifactMatchesSearch(: artifact.verified === false? 'unverified': undefined,+ artifact.running ? 'running' : undefined,artifact.protected ? 'protected' : 'unprotected',];return haystack.filter(Boolean).join(' ').toLowerCase().includes(normalizedTerm);diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx b/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsxindex d4b6ee6782..8b791a0e5e 100644--- a/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx+++ b/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx@@ -241,6 +241,9 @@ export function artifactStateLabel(artifact: RecoverableArtifact): string {if (artifact.sourceKind === 'snapshot') {return getProxmoxBackupSourcePresentation('snapshot').stateFallbackLabel;}+ // Running outranks everything: whatever else is true of the artifact, it+ // is not a restorable backup yet.+ if (artifact.running) return 'Running';if (artifact.protected) return 'Protected';if (artifact.verified === true) return 'Verified';if (artifact.verified === false) return 'Unverified';@@ -248,6 +251,13 @@ export function artifactStateLabel(artifact: RecoverableArtifact): string {}export function ArtifactStateBadge(props: { artifact: RecoverableArtifact; label: string }) {+ if (props.artifact.running) {+ return (+ <MetadataBadge {...PROXMOX_BACKUP_METADATA_BADGE_PROPS} tone="info">+ {props.label}+ </MetadataBadge>+ );+ }if (props.artifact.sourceKind === 'snapshot') {return (<MetadataBadge {...PROXMOX_BACKUP_METADATA_BADGE_PROPS} tone="indigo">diff --git a/frontend-modern/src/hooks/useWorkloads.ts b/frontend-modern/src/hooks/useWorkloads.tsindex 2bb8270c97..95b1a050cd 100644--- a/frontend-modern/src/hooks/useWorkloads.ts+++ b/frontend-modern/src/hooks/useWorkloads.ts@@ -97,6 +97,7 @@ type APIResource = {uptime?: number;template?: boolean;lastBackup?: string;+ backupInProgress?: boolean;disks?: APIDiskInfo[];swapUsed?: number;swapTotal?: number;@@ -576,6 +577,7 @@ const mapResourceToWorkload = (resource: APIResource): WorkloadGuest | null => {// Go zero time "0001-01-01T00:00:00Z" parses to a large negative numberreturn parsed > 0 ? parsed : 0;})(),+ backupInProgress: resource.proxmox?.backupInProgress ?? false,// vSphere's flat `resource.tags` is a mixed keyword set: the adapter keeps// provenance strings there (`vmware`, `vsphere`, `source:vcenter`, ...) so// resource search and the `?tags=` filter keep matching, and appends thediff --git a/frontend-modern/src/types/api.ts b/frontend-modern/src/types/api.tsindex b360850c0d..69d1a0b162 100644--- a/frontend-modern/src/types/api.ts+++ b/frontend-modern/src/types/api.ts@@ -208,6 +208,8 @@ export interface VM {uptime: number;template: boolean;lastBackup: number;+ /** A backup of this guest is running right now; lastBackup still points at the latest completed backup. */+ backupInProgress?: boolean;tags: string[] | string | null;lock: string;lastSeen: string;@@ -239,6 +241,8 @@ export interface Container {uptime: number;template: boolean;lastBackup: number;+ /** A backup of this guest is running right now; lastBackup still points at the latest completed backup. */+ backupInProgress?: boolean;tags: string[] | string | null;lock: string;lastSeen: string;@@ -725,6 +729,8 @@ export interface StorageBackup {isPBS: boolean;verified: boolean;verification?: string;+ /** Partial artifact a still-running backup is writing; not a completed backup. */+ inProgress?: boolean;}export interface GuestSnapshot {@@ -752,6 +758,8 @@ export interface PBSBackup {size: number;protected: boolean;verified: boolean;+ /** In-flight snapshot the backup client is still writing (no manifest yet); not a completed backup. */+ inProgress?: boolean;verificationRaw?: unknown;comment?: string;files: string[];diff --git a/frontend-modern/src/utils/__tests__/workloadGuestPresentation.test.ts b/frontend-modern/src/utils/__tests__/workloadGuestPresentation.test.tsindex 82baed940e..578a2432d3 100644--- a/frontend-modern/src/utils/__tests__/workloadGuestPresentation.test.ts+++ b/frontend-modern/src/utils/__tests__/workloadGuestPresentation.test.ts@@ -30,6 +30,22 @@ describe('workloadGuestPresentation', () => {expect(getWorkloadsGuestBackupTooltip('stale', '3d')).toBe('Last backup: 3d');});+ it('presents a running backup as its own state, keeping the completed age', () => {+ expect(getWorkloadsGuestBackupStatusPresentation('running')).toEqual({+ color: 'text-blue-600 dark:text-blue-400',+ bgColor: 'bg-blue-100 dark:bg-blue-900',+ icon: 'running',+ });+ // While a backup runs, the tooltip still reports the last COMPLETED+ // backup age - a started backup must never read as a finished one.+ expect(getWorkloadsGuestBackupTooltip('stale', '3d', true)).toBe(+ 'Backup running now · last backup: 3d',+ );+ expect(getWorkloadsGuestBackupTooltip('never', undefined, true)).toBe(+ 'Backup running now · no completed backup found',+ );+ });+it('returns canonical guest network and disk fallback copy', () => {expect(getWorkloadsGuestNetworkEmptyState()).toBe('No IP assigned');expect(getWorkloadGuestDiskStatusMessage('no-filesystems')).toBe(diff --git a/frontend-modern/src/utils/workloadGuestPresentation.ts b/frontend-modern/src/utils/workloadGuestPresentation.tsindex 2beea83b1c..cf4306c71e 100644--- a/frontend-modern/src/utils/workloadGuestPresentation.ts+++ b/frontend-modern/src/utils/workloadGuestPresentation.ts@@ -1,12 +1,20 @@import type { BackupStatus } from '@/utils/format';+// The age-derived BackupStatus plus the overlay state for a backup that is+// running right now. 'running' never comes from getBackupInfo (which only+// knows ages); callers overlay it from the guest's backupInProgress flag.+export type WorkloadsGuestBackupDisplayStatus = BackupStatus | 'running';+export interface WorkloadsGuestBackupStatusPresentation {color: string;bgColor: string;- icon: 'check' | 'warning' | 'x';+ icon: 'check' | 'warning' | 'x' | 'running';}-const BACKUP_STATUS_PRESENTATION: Record<BackupStatus, WorkloadsGuestBackupStatusPresentation> = {+const BACKUP_STATUS_PRESENTATION: Record<+ WorkloadsGuestBackupDisplayStatus,+ WorkloadsGuestBackupStatusPresentation+> = {fresh: {color: 'text-green-600 dark:text-green-400',bgColor: 'bg-green-100 dark:bg-green-900',@@ -27,10 +35,15 @@ const BACKUP_STATUS_PRESENTATION: Record<BackupStatus, WorkloadsGuestBackupStatubgColor: 'bg-red-100 dark:bg-red-900',icon: 'x',},+ running: {+ color: 'text-blue-600 dark:text-blue-400',+ bgColor: 'bg-blue-100 dark:bg-blue-900',+ icon: 'running',+ },};export function getWorkloadsGuestBackupStatusPresentation(- status: BackupStatus,+ status: WorkloadsGuestBackupDisplayStatus,): WorkloadsGuestBackupStatusPresentation {return BACKUP_STATUS_PRESENTATION[status];}@@ -38,11 +51,17 @@ export function getWorkloadsGuestBackupStatusPresentation(export function getWorkloadsGuestBackupTooltip(status: BackupStatus,ageFormatted?: string | null,+ backupRunning?: boolean,): string {+ const base =+ status === 'never' ? 'No completed backup found' : `Last backup: ${ageFormatted || 'Unknown'}`;+ if (backupRunning) {+ return `Backup running now · ${base.toLowerCase()}`;+ }if (status === 'never') {return 'No backup found';}- return `Last backup: ${ageFormatted || 'Unknown'}`;+ return base;}export function getWorkloadsGuestNetworkEmptyState(): string {diff --git a/internal/models/backup_in_progress_test.go b/internal/models/backup_in_progress_test.gonew file mode 100644index 0000000000..06f07d1b1c--- /dev/null+++ b/internal/models/backup_in_progress_test.go@@ -0,0 +1,181 @@+package models++import (+ "testing"+ "time"+)++// An in-flight PBS snapshot (no manifest yet) was previously counted as a+// completed backup: the guest's LastBackup jumped to "now" the moment vzdump+// started, and the badge showed a healthy backup that did not exist.+// These tests pin the corrected behaviour: in-progress evidence feeds+// BackupInProgress only, and LastBackup tracks completed backups.++func TestSyncGuestBackupTimesIgnoresInProgressPBSSnapshot(t *testing.T) {+ state := NewState()+ now := time.Now()+ completedTime := now.Add(-48 * time.Hour)+ inFlightTime := now.Add(-5 * time.Minute)++ state.UpdateVMs([]VM{+ {VMID: 117, Name: "win11-pvepc", Instance: "pve-pc", Node: "pve-pc"},+ })++ state.mu.Lock()+ state.PBSBackups = []PBSBackup{+ {ID: "done-117", VMID: "117", BackupType: "vm", BackupTime: completedTime,+ Instance: "verdeclose", Datastore: "main", Namespace: "pve-pc"},+ {ID: "flight-117", VMID: "117", BackupType: "vm", BackupTime: inFlightTime,+ Instance: "verdeclose", Datastore: "main", Namespace: "pve-pc", InProgress: true},+ }+ state.mu.Unlock()++ state.SyncGuestBackupTimes()+ snapshot := state.GetSnapshot()++ if len(snapshot.VMs) != 1 {+ t.Fatalf("expected 1 VM, got %d", len(snapshot.VMs))+ }+ vm := snapshot.VMs[0]+ if !vm.LastBackup.Equal(completedTime) {+ t.Errorf("LastBackup = %v, want the completed snapshot %v (in-flight one must not advance it)",+ vm.LastBackup, completedTime)+ }+ if !vm.BackupInProgress {+ t.Error("BackupInProgress = false, want true while an in-flight snapshot exists")+ }+}++func TestSyncGuestBackupTimesInProgressOnlyNeverSetsLastBackup(t *testing.T) {+ state := NewState()++ state.UpdateVMs([]VM{+ {VMID: 117, Name: "win11-pvepc", Instance: "pve-pc", Node: "pve-pc"},+ })++ state.mu.Lock()+ state.PBSBackups = []PBSBackup{+ {ID: "flight-117", VMID: "117", BackupType: "vm", BackupTime: time.Now(),+ Instance: "verdeclose", Datastore: "main", Namespace: "pve-pc", InProgress: true},+ }+ state.mu.Unlock()++ state.SyncGuestBackupTimes()+ snapshot := state.GetSnapshot()++ vm := snapshot.VMs[0]+ if !vm.LastBackup.IsZero() {+ t.Errorf("LastBackup = %v, want zero: the guest has no completed backup", vm.LastBackup)+ }+ if !vm.BackupInProgress {+ t.Error("BackupInProgress = false, want true")+ }+}++func TestSyncGuestBackupTimesRunningVzdumpTaskSetsBackupInProgress(t *testing.T) {+ state := NewState()+ now := time.Now()++ state.UpdateContainers([]Container{+ {VMID: 105, Name: "media", Instance: "homelab", Node: "minipc"},+ })++ state.mu.Lock()+ state.PVEBackups.BackupTasks = []BackupTask{+ {ID: "homelab-upid1", Instance: "homelab", Node: "minipc", Type: "vzdump",+ VMID: 105, Status: "running", StartTime: now.Add(-10 * time.Minute),+ ObservedAt: now},+ }+ state.mu.Unlock()++ state.SyncGuestBackupTimes()+ snapshot := state.GetSnapshot()++ ct := snapshot.Containers[0]+ if !ct.BackupInProgress {+ t.Error("BackupInProgress = false, want true while a vzdump task is running")+ }+ if !ct.LastBackup.IsZero() {+ t.Errorf("LastBackup = %v, want zero", ct.LastBackup)+ }+}++func TestSyncGuestBackupTimesIgnoresStaleRunningTask(t *testing.T) {+ state := NewState()+ now := time.Now()++ state.UpdateVMs([]VM{+ {VMID: 200, Name: "old", Instance: "homelab", Node: "delly"},+ })++ state.mu.Lock()+ state.PVEBackups.BackupTasks = []BackupTask{+ // Unfinished task last observed two days ago: the instance stopped+ // refreshing, so this must not pin the guest as backing up.+ {ID: "homelab-upid2", Instance: "homelab", Node: "delly", Type: "vzdump",+ VMID: 200, Status: "running", StartTime: now.Add(-49 * time.Hour),+ ObservedAt: now.Add(-48 * time.Hour)},+ }+ state.mu.Unlock()++ state.SyncGuestBackupTimes()+ snapshot := state.GetSnapshot()++ if snapshot.VMs[0].BackupInProgress {+ t.Error("BackupInProgress = true, want false for a stale running task")+ }+}++func TestSyncGuestBackupTimesIgnoresInProgressStorageBackup(t *testing.T) {+ state := NewState()+ now := time.Now()+ completedTime := now.Add(-24 * time.Hour)++ state.UpdateVMs([]VM{+ {VMID: 117, Name: "win11-pvepc", Instance: "pve-pc", Node: "pve-pc"},+ })++ state.mu.Lock()+ state.PVEBackups.StorageBackups = []StorageBackup{+ {ID: "pve-pc-old", Instance: "pve-pc", Node: "pve-pc", Type: "qemu",+ VMID: 117, Time: completedTime, Size: 42 << 30},+ // Partial archive a running vzdump is still writing.+ {ID: "pve-pc-partial", Instance: "pve-pc", Node: "pve-pc", Type: "qemu",+ VMID: 117, Time: now.Add(-3 * time.Minute), Size: 7 << 30, InProgress: true},+ }+ state.mu.Unlock()++ state.SyncGuestBackupTimes()+ snapshot := state.GetSnapshot()++ vm := snapshot.VMs[0]+ if !vm.LastBackup.Equal(completedTime) {+ t.Errorf("LastBackup = %v, want completed archive time %v", vm.LastBackup, completedTime)+ }+}++// Guest polls know nothing about backups; the instance merge must carry the+// backup-running flag forward alongside LastBackup so it does not flap off+// between backup sync passes.+func TestUpdateVMsForInstancePreservesBackupInProgress(t *testing.T) {+ state := NewState()++ state.UpdateVMs([]VM{+ {ID: "pve-pc-117", VMID: 117, Name: "win11-pvepc", Instance: "pve-pc", Node: "pve-pc",+ LastBackup: time.Now().Add(-24 * time.Hour), BackupInProgress: true},+ })++ // Fresh poll data: no backup knowledge at all.+ state.UpdateVMsForInstance("pve-pc", []VM{+ {ID: "pve-pc-117", VMID: 117, Name: "win11-pvepc", Instance: "pve-pc", Node: "pve-pc"},+ })++ snapshot := state.GetSnapshot()+ vm := snapshot.VMs[0]+ if vm.LastBackup.IsZero() {+ t.Error("LastBackup lost across instance update")+ }+ if !vm.BackupInProgress {+ t.Error("BackupInProgress lost across instance update")+ }+}diff --git a/internal/models/models.go b/internal/models/models.goindex b40918dd88..79903b9210 100644--- a/internal/models/models.go+++ b/internal/models/models.go@@ -200,9 +200,13 @@ type VM struct {Template bool `json:"template"`OnBoot *bool `json:"onBoot,omitempty"`LastBackup time.Time `json:"lastBackup,omitempty"`- Tags []string `json:"tags,omitempty"`- Lock string `json:"lock,omitempty"`- LastSeen time.Time `json:"lastSeen"`+ // BackupInProgress reports that a backup of this guest is running right+ // now (a live vzdump task, or an in-flight PBS snapshot). LastBackup+ // still points at the most recent COMPLETED backup while this is set.+ BackupInProgress bool `json:"backupInProgress,omitempty"`+ Tags []string `json:"tags,omitempty"`+ Lock string `json:"lock,omitempty"`+ LastSeen time.Time `json:"lastSeen"`}func (v VM) NormalizeCollections() VM {@@ -226,28 +230,32 @@ func (v VM) NormalizeCollections() VM {// Container represents an LXC containertype Container struct {- ID string `json:"id"`- VMID int `json:"vmid"`- Name string `json:"name"`- Node string `json:"node"`- Pool string `json:"pool,omitempty"`- Instance string `json:"instance"`- Status string `json:"status"`- Type string `json:"type"`- CPU float64 `json:"cpu"`- CPUs int `json:"cpus"`- Memory Memory `json:"memory"`- Disk Disk `json:"disk"`- Disks []Disk `json:"disks,omitempty"`- NetworkIn int64 `json:"networkIn"`- NetworkOut int64 `json:"networkOut"`- DiskRead int64 `json:"diskRead"`- DiskWrite int64 `json:"diskWrite"`- IORateValidity IORateValidity `json:"-"`- Uptime int64 `json:"uptime"`- Template bool `json:"template"`- OnBoot *bool `json:"onBoot,omitempty"`- LastBackup time.Time `json:"lastBackup,omitempty"`+ ID string `json:"id"`+ VMID int `json:"vmid"`+ Name string `json:"name"`+ Node string `json:"node"`+ Pool string `json:"pool,omitempty"`+ Instance string `json:"instance"`+ Status string `json:"status"`+ Type string `json:"type"`+ CPU float64 `json:"cpu"`+ CPUs int `json:"cpus"`+ Memory Memory `json:"memory"`+ Disk Disk `json:"disk"`+ Disks []Disk `json:"disks,omitempty"`+ NetworkIn int64 `json:"networkIn"`+ NetworkOut int64 `json:"networkOut"`+ DiskRead int64 `json:"diskRead"`+ DiskWrite int64 `json:"diskWrite"`+ IORateValidity IORateValidity `json:"-"`+ Uptime int64 `json:"uptime"`+ Template bool `json:"template"`+ OnBoot *bool `json:"onBoot,omitempty"`+ LastBackup time.Time `json:"lastBackup,omitempty"`+ // BackupInProgress reports that a backup of this guest is running right+ // now (a live vzdump task, or an in-flight PBS snapshot). LastBackup+ // still points at the most recent COMPLETED backup while this is set.+ BackupInProgress bool `json:"backupInProgress,omitempty"`Tags []string `json:"tags,omitempty"`Lock string `json:"lock,omitempty"`LastSeen time.Time `json:"lastSeen"`@@ -2741,20 +2749,25 @@ type PBSNamespace struct {// PBSBackup represents a backup stored on PBStype PBSBackup struct {- ID string `json:"id"` // Unique ID combining PBS instance, namespace, type, vmid, and time- Instance string `json:"instance"` // PBS instance name- Datastore string `json:"datastore"`- Namespace string `json:"namespace"`- BackupType string `json:"backupType"` // "vm" or "ct"- VMID string `json:"vmid"`- BackupTime time.Time `json:"backupTime"`- Size int64 `json:"size"`- Protected bool `json:"protected"`- Verified bool `json:"verified"`- VerificationRaw any `json:"verificationRaw,omitempty"`- Comment string `json:"comment,omitempty"`- Files []string `json:"files"`- Owner string `json:"owner,omitempty"` // User who created the backup+ ID string `json:"id"` // Unique ID combining PBS instance, namespace, type, vmid, and time+ Instance string `json:"instance"` // PBS instance name+ Datastore string `json:"datastore"`+ Namespace string `json:"namespace"`+ BackupType string `json:"backupType"` // "vm" or "ct"+ VMID string `json:"vmid"`+ BackupTime time.Time `json:"backupTime"`+ Size int64 `json:"size"`+ Protected bool `json:"protected"`+ Verified bool `json:"verified"`+ // InProgress marks a snapshot the PBS API listed while the backup is+ // still being written: the manifest (index.json.blob) does not exist yet,+ // so the listing has no size and only the guest config blob in files. It+ // is not a completed backup and must not advance any last-backup age.+ InProgress bool `json:"inProgress,omitempty"`+ VerificationRaw any `json:"verificationRaw,omitempty"`+ Comment string `json:"comment,omitempty"`+ Files []string `json:"files"`+ Owner string `json:"owner,omitempty"` // User who created the backup}func (b PBSBackup) NormalizeCollections() PBSBackup {@@ -3244,6 +3257,11 @@ type StorageBackup struct {IsPBS bool `json:"isPBS"` // Indicates if backup is on PBS storageVerified bool `json:"verified"` // PBS verification statusVerification string `json:"verification,omitempty"` // Verification details+ // InProgress marks a backup file that a still-running vzdump task for the+ // same guest is currently writing (or a PBS-storage listing entry whose+ // snapshot has no manifest yet). It is a partial artifact, not a+ // completed backup, and must not advance any last-backup age.+ InProgress bool `json:"inProgress,omitempty"`}// GuestSnapshot represents a VM/CT snapshot@@ -4176,7 +4194,7 @@ func updateSliceByInstanceWithBackup[T any, K int | int64](getInstance func(T) string,getVMID func(T) K,getLastBackup func(T) time.Time,- setLastBackup func(T, time.Time) T,+ carryBackupState func(item T, prev T) T,clone func(T) T,less func([]T, int, int) bool,) []T {@@ -4195,8 +4213,11 @@ func updateSliceByInstanceWithBackup[T any, K int | int64](}for _, item := range newItems {item = clone(item)- if existing, ok := existingByVMID[getVMID(item)]; ok && getLastBackup(item).IsZero() {- item = setLastBackup(item, getLastBackup(existing))+ // Guest polls know nothing about backups (LastBackup arrives zero);+ // carry the previously computed backup state forward so it survives+ // until the next SyncGuestBackupTimes pass recomputes it.+ if prev, ok := existingByVMID[getVMID(item)]; ok && getLastBackup(item).IsZero() {+ item = carryBackupState(item, prev)}itemMap[getID(item)] = item}@@ -4217,7 +4238,7 @@ func updateSliceForInstance[T any, K int | int64](getInstance func(T) string,getVMID func(T) K,getLastBackup func(T) time.Time,- setLastBackup func(T, time.Time) T,+ carryBackupState func(item T, prev T) T,clone func(T) T,less func([]T, int, int) bool,) {@@ -4226,7 +4247,7 @@ func updateSliceForInstance[T any, K int | int64](*slicePtr = updateSliceByInstanceWithBackup(*slicePtr, newItems, instanceName,- getID, getInstance, getVMID, getLastBackup, setLastBackup, clone, less,+ getID, getInstance, getVMID, getLastBackup, carryBackupState, clone, less,)s.LastUpdate = time.Now()}@@ -4239,7 +4260,11 @@ func (s *State) UpdateVMsForInstance(instanceName string, vms []VM) {func(vm VM) string { return vm.Instance },func(vm VM) int { return vm.VMID },func(vm VM) time.Time { return vm.LastBackup },- func(vm VM, t time.Time) VM { vm.LastBackup = t; return vm },+ func(vm VM, prev VM) VM {+ vm.LastBackup = prev.LastBackup+ vm.BackupInProgress = prev.BackupInProgress+ return vm+ },cloneVM,func(items []VM, i, j int) bool { return items[i].VMID < items[j].VMID },)@@ -4257,6 +4282,12 @@ func (s *State) UpdateContainers(containers []Container) {s.LastUpdate = time.Now()}+// runningBackupTaskMaxAge bounds how long an unfinished vzdump task keeps+// reporting a guest as backing up. Task lists stop refreshing for an+// unreachable instance, and a wedged multi-day vzdump is not a state worth+// advertising as "running" on the guest badge.+const runningBackupTaskMaxAge = 24 * time.Hour+// backupKey creates a composite key for backup matching using instance and VMID.// This ensures backups are correctly matched to guests even when VMIDs are reused across instances.func backupKey(instance string, vmid int) string {@@ -4331,7 +4362,10 @@ func (s *State) PBSGuestConfirmationsForInstance(instanceName string) []PBSGuestreturn out}-// SyncGuestBackupTimes updates LastBackup on VMs and Containers from storage backups and PBS backups.+// SyncGuestBackupTimes updates LastBackup and BackupInProgress on VMs and+// Containers from storage backups, PBS backups, and running backup tasks.+// LastBackup only ever reflects completed backups; in-flight PBS snapshots+// and partial vzdump archives surface through BackupInProgress instead.// Call this after updating storage backups or PBS backups to ensure guest backup indicators are accurate.// Matching is done by instance+VMID to prevent cross-instance VMID collisions.// For PBS backups with namespaces, namespace matching is ranked against the guest's node and@@ -4349,11 +4383,45 @@ func (s *State) SyncGuestBackupTimes() {// Using composite key prevents cross-instance VMID collision issueslatestBackup := make(map[string]time.Time)+ // Guests with a backup running right now: a live vzdump task is the+ // authoritative PVE-side signal. Partial artifacts (an in-flight PBS+ // snapshot, a half-written vzdump archive) are collected separately+ // below so they can surface as "backup running" without ever advancing+ // the last-completed-backup age.+ runningBackupTask := make(map[string]struct{})+ runningTaskCutoff := time.Now().Add(-runningBackupTaskMaxAge)+ for _, task := range s.PVEBackups.BackupTasks {+ if task.VMID <= 0 || task.Instance == "" || !task.EndTime.IsZero() {+ continue+ }+ status := strings.ToLower(strings.TrimSpace(task.Status))+ if status != "" && status != "running" {+ continue+ }+ // Task lists stop refreshing when an instance goes unreachable, so a+ // stale "running" entry must eventually age out rather than pin the+ // guest in a backup-running state forever. ObservedAt refreshes on+ // every poll; tasks synthesized from job logs carry only StartTime.+ observed := task.ObservedAt+ if observed.IsZero() {+ observed = task.StartTime+ }+ if observed.Before(runningTaskCutoff) {+ continue+ }+ runningBackupTask[backupKey(task.Instance, task.VMID)] = struct{}{}+ }+// Process PVE storage backupsfor _, backup := range s.PVEBackups.StorageBackups {if backup.VMID <= 0 || backup.Instance == "" {continue}+ if backup.InProgress {+ // A partial file is not a completed backup; the running-task set+ // above already reports the guest as backing up.+ continue+ }key := backupKey(backup.Instance, backup.VMID)if existing, ok := latestBackup[key]; !ok || backup.Time.After(existing) {latestBackup[key] = backup.Time@@ -4362,7 +4430,10 @@ func (s *State) SyncGuestBackupTimes() {// Process PBS backups (VMID is string, BackupTime is the timestamp).// Group by PBS subject type and VMID so VM and CT IDs do not cross-match.+ // In-flight snapshots are kept apart: they only feed the backup-running+ // flag, never the completed-backup ages or the attribution learner.pbsBackupsBySubject := make(map[pbsSubjectKey][]PBSBackup)+ pbsInProgressBySubject := make(map[pbsSubjectKey][]PBSBackup)for _, backup := range s.PBSBackups {vmid, err := strconv.Atoi(backup.VMID)if err != nil || vmid <= 0 {@@ -4373,6 +4444,10 @@ func (s *State) SyncGuestBackupTimes() {continue}key := pbsSubjectKey{backupType: backupType, vmid: vmid}+ if backup.InProgress {+ pbsInProgressBySubject[key] = append(pbsInProgressBySubject[key], backup)+ continue+ }pbsBackupsBySubject[key] = append(pbsBackupsBySubject[key], backup)}@@ -4519,10 +4594,12 @@ func (s *State) SyncGuestBackupTimes() {// findBestPBSBackup finds the best PBS backup for a given typed VMID and guest location.// Placement and guest-name matches are preferred over VMID-only fallback.- // Returns zero time if no suitable backup found.- findBestPBSBackup := func(vmid int, backupType string, instance string, node string, name string) time.Time {+ // Returns zero time if no suitable backup found. The subject map is a+ // parameter so the same attribution rules apply to completed snapshots+ // (feeding LastBackup) and to in-flight ones (feeding BackupInProgress).+ findBestPBSBackup := func(bySubject map[pbsSubjectKey][]PBSBackup, vmid int, backupType string, instance string, node string, name string) time.Time {subjectKey := pbsSubjectKey{backupType: backupType, vmid: vmid}- backups, ok := pbsBackupsBySubject[subjectKey]+ backups, ok := bySubject[subjectKey]if !ok || len(backups) == 0 {return time.Time{}}@@ -4589,13 +4666,16 @@ func (s *State) SyncGuestBackupTimes() {lastBackup = backupTime}// Check if PBS has a more recent backup- pbsTime := findBestPBSBackup(s.VMs[i].VMID, "vm", s.VMs[i].Instance, s.VMs[i].Node, s.VMs[i].Name)+ pbsTime := findBestPBSBackup(pbsBackupsBySubject, s.VMs[i].VMID, "vm", s.VMs[i].Instance, s.VMs[i].Node, s.VMs[i].Name)if !pbsTime.IsZero() {if lastBackup.IsZero() || pbsTime.After(lastBackup) {lastBackup = pbsTime}}s.VMs[i].LastBackup = lastBackup+ _, taskRunning := runningBackupTask[key]+ s.VMs[i].BackupInProgress = taskRunning ||+ !findBestPBSBackup(pbsInProgressBySubject, s.VMs[i].VMID, "vm", s.VMs[i].Instance, s.VMs[i].Node, s.VMs[i].Name).IsZero()}// Update Containers - recompute from current backup evidence instead of preserving stale values@@ -4606,13 +4686,16 @@ func (s *State) SyncGuestBackupTimes() {lastBackup = backupTime}// Check if PBS has a more recent backup- pbsTime := findBestPBSBackup(s.Containers[i].VMID, "ct", s.Containers[i].Instance, s.Containers[i].Node, s.Containers[i].Name)+ pbsTime := findBestPBSBackup(pbsBackupsBySubject, s.Containers[i].VMID, "ct", s.Containers[i].Instance, s.Containers[i].Node, s.Containers[i].Name)if !pbsTime.IsZero() {if lastBackup.IsZero() || pbsTime.After(lastBackup) {lastBackup = pbsTime}}s.Containers[i].LastBackup = lastBackup+ _, taskRunning := runningBackupTask[key]+ s.Containers[i].BackupInProgress = taskRunning ||+ !findBestPBSBackup(pbsInProgressBySubject, s.Containers[i].VMID, "ct", s.Containers[i].Instance, s.Containers[i].Node, s.Containers[i].Name).IsZero()}s.LastUpdate = time.Now()@@ -4626,7 +4709,11 @@ func (s *State) UpdateContainersForInstance(instanceName string, containers []Cofunc(ct Container) string { return ct.Instance },func(ct Container) int { return ct.VMID },func(ct Container) time.Time { return ct.LastBackup },- func(ct Container, t time.Time) Container { ct.LastBackup = t; return ct },+ func(ct Container, prev Container) Container {+ ct.LastBackup = prev.LastBackup+ ct.BackupInProgress = prev.BackupInProgress+ return ct+ },cloneContainer,func(items []Container, i, j int) bool { return items[i].VMID < items[j].VMID },)diff --git a/internal/models/proxmox_guest_state.go b/internal/models/proxmox_guest_state.goindex 467b4d65e7..b4f357ed7a 100644--- a/internal/models/proxmox_guest_state.go+++ b/internal/models/proxmox_guest_state.go@@ -16,7 +16,11 @@ func (s *State) UpdateGuestsForInstance(instanceName string, vms []VM, containerfunc(vm VM) string { return vm.Instance },func(vm VM) int { return vm.VMID },func(vm VM) time.Time { return vm.LastBackup },- func(vm VM, t time.Time) VM { vm.LastBackup = t; return vm },+ func(vm VM, prev VM) VM {+ vm.LastBackup = prev.LastBackup+ vm.BackupInProgress = prev.BackupInProgress+ return vm+ },cloneVM,func(items []VM, i, j int) bool { return items[i].VMID < items[j].VMID },)@@ -26,7 +30,11 @@ func (s *State) UpdateGuestsForInstance(instanceName string, vms []VM, containerfunc(ct Container) string { return ct.Instance },func(ct Container) int { return ct.VMID },func(ct Container) time.Time { return ct.LastBackup },- func(ct Container, t time.Time) Container { ct.LastBackup = t; return ct },+ func(ct Container, prev Container) Container {+ ct.LastBackup = prev.LastBackup+ ct.BackupInProgress = prev.BackupInProgress+ return ct+ },cloneContainer,func(items []Container, i, j int) bool { return items[i].VMID < items[j].VMID },)diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.goindex 4b912b31f4..a8e1e52309 100644--- a/internal/monitoring/monitor.go+++ b/internal/monitoring/monitor.go@@ -3469,6 +3469,7 @@ func vmFromReadStateView(view *unifiedresources.VMView) models.VM {Uptime: view.Uptime(),Template: view.Template(),LastBackup: view.LastBackup(),+ BackupInProgress: view.BackupInProgress(),Tags: view.Tags(),Lock: view.Lock(),LastSeen: view.LastSeen(),@@ -3505,6 +3506,7 @@ func containerFromReadStateView(view *unifiedresources.ContainerView) models.ConUptime: view.Uptime(),Template: view.Template(),LastBackup: view.LastBackup(),+ BackupInProgress: view.BackupInProgress(),Tags: view.Tags(),Lock: view.Lock(),LastSeen: view.LastSeen(),@@ -6808,12 +6810,15 @@ func buildProxmoxVMPayload(resource unifiedresources.Resource) map[string]interf"diskWrite": monitorMetricInt64(resource.Metrics, func(metrics *unifiedresources.ResourceMetrics) *unifiedresources.MetricValue {return metrics.DiskWrite}),- "disks": convertProxmoxDisks(resource.Proxmox.Disks),- "swapUsed": resource.Proxmox.SwapUsed,- "swapTotal": resource.Proxmox.SwapTotal,- "balloon": resource.Proxmox.Balloon,- "lastBackup": resource.Proxmox.LastBackup,- "ipAddresses": append([]string(nil), resource.Identity.IPAddresses...),+ "disks": convertProxmoxDisks(resource.Proxmox.Disks),+ "swapUsed": resource.Proxmox.SwapUsed,+ "swapTotal": resource.Proxmox.SwapTotal,+ "balloon": resource.Proxmox.Balloon,+ "lastBackup": resource.Proxmox.LastBackup,+ // A backup of this guest is running right now; lastBackup still+ // points at the latest completed backup.+ "backupInProgress": resource.Proxmox.BackupInProgress,+ "ipAddresses": append([]string(nil), resource.Identity.IPAddresses...),}}diff --git a/internal/monitoring/monitor_backups.go b/internal/monitoring/monitor_backups.goindex 3c9a1f9e05..832b207e15 100644--- a/internal/monitoring/monitor_backups.go+++ b/internal/monitoring/monitor_backups.go@@ -24,6 +24,11 @@ import (const (pbsBackupSnapshotFetchWorkers = 5+ // runningVzdumpClockSkew is the slack applied when deciding whether a+ // backup file's ctime falls inside a running vzdump task's window, so a+ // small clock offset between Pulse and the node cannot misclassify the+ // task's own partial output as a completed backup.+ runningVzdumpClockSkew = 2 * time.Minute// pbsBackupSnapshotsPerGroupLimit bounds how many real snapshots are// retained per backup group (newest first). It must comfortably exceed// common PBS keep policies: groups are always represented by real fetched@@ -169,6 +174,26 @@ func (m *Monitor) pollStorageBackupsWithNodes(ctx context.Context, instanceNameguestNodeMap := make(map[int]string) // VMID -> actual node namepopulateGuestNodeMapFromReadState(readState, instanceName, guestNodeMap)+ // vzdump writes archives under their final name, so a backup that is+ // still running is already listed by the storage content API as a+ // growing partial file. Correlate content entries with the live vzdump+ // tasks polled just before this pass (pollBackupTasks runs first in the+ // cycle): a guest backup file created at or after a running task's start+ // is that task's partial output, not a completed backup.+ runningVzdumpStart := make(map[int]time.Time) // VMID -> earliest running task start+ for _, task := range snapshot.PVEBackups.BackupTasks {+ if task.Instance != instanceName || task.VMID <= 0 || !task.EndTime.IsZero() {+ continue+ }+ status := strings.ToLower(strings.TrimSpace(task.Status))+ if status != "" && status != "running" {+ continue+ }+ if existing, ok := runningVzdumpStart[task.VMID]; !ok || task.StartTime.Before(existing) {+ runningVzdumpStart[task.VMID] = task.StartTime+ }+ }+// For each node, get storage and check contentfor _, node := range nodes {if nodeEffectiveStatus[node.Node] != "online" {@@ -355,6 +380,21 @@ func (m *Monitor) pollStorageBackupsWithNodes(ctx context.Context, instanceName}}+ // Partial-output window: the file belongs to a vzdump task+ // that is still running. PBS-type storages additionally list+ // in-flight snapshots without a size (no manifest yet), which+ // covers backups submitted by another cluster or host.+ inProgress := false+ if content.VMID > 0 {+ if start, ok := runningVzdumpStart[content.VMID]; ok &&+ !time.Unix(content.CTime, 0).Before(start.Add(-runningVzdumpClockSkew)) {+ inProgress = true+ }+ if isPBSStorage && content.Size == 0 {+ inProgress = true+ }+ }+backup := models.StorageBackup{ID: fmt.Sprintf("%s-%s", instanceName, content.Volid),Storage: storage.Storage,@@ -372,6 +412,7 @@ func (m *Monitor) pollStorageBackupsWithNodes(ctx context.Context, instanceNameIsPBS: isPBSStorage,Verified: verified,Verification: verificationInfo,+ InProgress: inProgress,}allBackups = append(allBackups, backup)@@ -1638,11 +1679,25 @@ func (m *Monitor) pollPBSBackups(ctx context.Context, instanceName string, cliencacheAge := time.Since(m.pbsBackupCacheTimeFor(instanceName, key))cacheStillFresh := cacheAge < pbsBackupCacheTTL+ // A cached in-flight snapshot must be re-fetched every poll:+ // when it completes, neither the group's last-backup time nor+ // its count changes (the listing already included it), so the+ // normal reuse conditions would keep showing "backup running"+ // until the TTL expired.+ cachedHasInProgress := false+ for _, cachedSnapshot := range cached.snapshots {+ if cachedSnapshot.InProgress {+ cachedHasInProgress = true+ break+ }+ }+// Only re-fetch when the backup count changes, the most recent backup// is newer, or the cache TTL has expired (to pick up verification changes).if hasCachedData &&cacheStillFresh &&cacheCountMatches &&+ !cachedHasInProgress &&!lastBackupTime.After(cached.latest) {allBackups = appendPBSBackupsWithinLimit(allBackups, cached.snapshots)@@ -2029,6 +2084,19 @@ func convertPBSSnapshots(instanceName, datastore, namespace string, snapshots []}}+ // A snapshot the PBS API lists while the backup is still being+ // written has no manifest yet: no size field (decoded as 0) and no+ // index.json.blob in files - typically only the guest config blob.+ // Treat it as in-progress, not as a completed backup.+ hasManifest := false+ for _, name := range fileNames {+ if name == "index.json.blob" {+ hasManifest = true+ break+ }+ }+ inProgress := snapshot.Size == 0 && !hasManifest+verified := falseif snapshot.Verification != nil {switch v := snapshot.Verification.(type) {@@ -2059,6 +2127,7 @@ func convertPBSSnapshots(instanceName, datastore, namespace string, snapshots []Size: snapshot.Size,Protected: snapshot.Protected,Verified: verified,+ InProgress: inProgress,VerificationRaw: snapshot.Verification,Comment: snapshot.Comment,Files: fileNames,diff --git a/internal/monitoring/pbs_convert_test.go b/internal/monitoring/pbs_convert_test.goindex f524fe7498..2dad18c5a9 100644--- a/internal/monitoring/pbs_convert_test.go+++ b/internal/monitoring/pbs_convert_test.go@@ -377,3 +377,75 @@ func TestConvertPBSSnapshots(t *testing.T) {}})}++// An in-flight snapshot (backup still being written) is listed by the PBS API+// without a size and without the manifest (index.json.blob) - typically only+// the guest config blob exists yet. It must be flagged InProgress so nothing+// downstream treats it as a completed backup.+func TestConvertPBSSnapshotsInProgress(t *testing.T) {+ tests := []struct {+ name string+ snapshot pbs.BackupSnapshot+ inProgress bool+ }{+ {+ name: "no size and only config blob is in-progress",+ snapshot: pbs.BackupSnapshot{+ BackupType: "vm",+ BackupID: "117",+ BackupTime: 1787221141,+ Files: []interface{}{map[string]interface{}{"filename": "qemu-server.conf.blob"}},+ Owner: "admin@pbs!pve-homelab",+ },+ inProgress: true,+ },+ {+ name: "completed snapshot with manifest and size",+ snapshot: pbs.BackupSnapshot{+ BackupType: "vm",+ BackupID: "117",+ BackupTime: 1787221141,+ Size: 80 << 30,+ Files: []interface{}{+ "qemu-server.conf.blob",+ "drive-scsi0.img.fidx",+ "index.json.blob",+ },+ },+ inProgress: false,+ },+ {+ name: "manifest present but size missing still counts as complete",+ snapshot: pbs.BackupSnapshot{+ BackupType: "ct",+ BackupID: "105",+ BackupTime: 1787221141,+ Files: []interface{}{"root.pxar.didx", "index.json.blob"},+ },+ inProgress: false,+ },+ {+ name: "size present without manifest counts as complete",+ snapshot: pbs.BackupSnapshot{+ BackupType: "vm",+ BackupID: "100",+ BackupTime: 1787221141,+ Size: 2048,+ Files: []interface{}{"drive-scsi0.img.fidx"},+ },+ inProgress: false,+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ result := convertPBSSnapshots("pbs-1", "main", "pve-pc", []pbs.BackupSnapshot{tt.snapshot})+ if len(result) != 1 {+ t.Fatalf("expected 1 backup, got %d", len(result))+ }+ if result[0].InProgress != tt.inProgress {+ t.Errorf("InProgress: expected %t, got %t", tt.inProgress, result[0].InProgress)+ }+ })+ }+}diff --git a/internal/recovery/mapper/proxmox/mapper.go b/internal/recovery/mapper/proxmox/mapper.goindex a596d49c8f..1dc5401a8a 100644--- a/internal/recovery/mapper/proxmox/mapper.go+++ b/internal/recovery/mapper/proxmox/mapper.go@@ -294,14 +294,25 @@ func FromPVEStorageBackups(backups []models.StorageBackup, guestInfoByKey map[stverifiedPtr = &verified}+ // A partial archive that a running vzdump task is still writing is a+ // running recovery point, not a completed one: no completion time,+ // and verification is not applicable yet.+ outcome := recovery.OutcomeSuccess+ completedAt := &t+ if b.InProgress {+ outcome = recovery.OutcomeRunning+ completedAt = nil+ verifiedPtr = nil+ }+out = append(out, recovery.RecoveryPoint{ID: "pve-backup:" + strings.TrimSpace(b.ID),Provider: recovery.ProviderProxmoxPVE,Kind: recovery.KindBackup,Mode: mode,- Outcome: recovery.OutcomeSuccess,+ Outcome: outcome,StartedAt: &t,- CompletedAt: &t,+ CompletedAt: completedAt,SizeBytes: sizePtr(b.Size),Verified: verifiedPtr,Immutable: immutable,@@ -319,6 +330,7 @@ func FromPVEStorageBackups(backups []models.StorageBackup, guestInfoByKey map[st"notes": strings.TrimSpace(b.Notes),"volid": strings.TrimSpace(b.Volid),"isPBS": b.IsPBS,+ "inProgress": b.InProgress,"verification": strings.TrimSpace(b.Verification),"type": strings.TrimSpace(b.Type),"instance": instanceName,@@ -534,6 +546,19 @@ func FromPBSBackups(backups []models.PBSBackup, candidatesByKey map[string][]Gue"comment": strings.TrimSpace(b.Comment),"owner": strings.TrimSpace(b.Owner),"files": append([]string(nil), b.Files...),+ "inProgress": b.InProgress,+ }++ // An in-flight snapshot (no manifest yet) is a running recovery+ // point: it has no completion time and cannot be verified. Keeping+ // it out of OutcomeSuccess also keeps posture/rollup freshness+ // anchored to the last COMPLETED backup.+ outcome := recovery.OutcomeSuccess+ completedAt := &t+ if b.InProgress {+ outcome = recovery.OutcomeRunning+ completedAt = nil+ verifiedPtr = nil}// Extract verification detail for frontend stability.@@ -554,9 +579,9 @@ func FromPBSBackups(backups []models.PBSBackup, candidatesByKey map[string][]GueProvider: recovery.ProviderProxmoxPBS,Kind: recovery.KindBackup,Mode: recovery.ModeRemote,- Outcome: recovery.OutcomeSuccess,+ Outcome: outcome,StartedAt: &t,- CompletedAt: &t,+ CompletedAt: completedAt,SizeBytes: sizePtr(b.Size),Verified: verifiedPtr,Immutable: immutable,diff --git a/internal/recovery/mapper/proxmox/mapper_test.go b/internal/recovery/mapper/proxmox/mapper_test.goindex eb88accf1a..bab2042bb0 100644--- a/internal/recovery/mapper/proxmox/mapper_test.go+++ b/internal/recovery/mapper/proxmox/mapper_test.go@@ -749,3 +749,80 @@ func TestFromPBSBackups_InvisibleClusterKeepsCollisionSnapshotUnlinked(t *testin}}}++// An in-flight PBS snapshot (no manifest yet) must map to a running recovery+// point: no completion time, no verification verdict, and never+// OutcomeSuccess - otherwise posture freshness treats a backup that merely+// STARTED as one that finished.+func TestFromPBSBackups_InProgressMapsToRunning(t *testing.T) {+ started := time.Date(2026, 8, 20, 9, 39, 1, 0, time.UTC)+ backups := []models.PBSBackup{+ {+ ID: "pbs-verdeclose-main-pve-pc-vm-117-1787221141",+ VMID: "117",+ Instance: "verdeclose",+ Datastore: "main",+ Namespace: "pve-pc",+ BackupType: "vm",+ BackupTime: started,+ Files: []string{"qemu-server.conf.blob"},+ InProgress: true,+ },+ }++ result := FromPBSBackups(backups, nil)+ if len(result) != 1 {+ t.Fatalf("expected 1 point, got %d", len(result))+ }++ p := result[0]+ if p.Outcome != recovery.OutcomeRunning {+ t.Errorf("Outcome = %v, want %v", p.Outcome, recovery.OutcomeRunning)+ }+ if p.CompletedAt != nil {+ t.Errorf("CompletedAt = %v, want nil for a running backup", p.CompletedAt)+ }+ if p.StartedAt == nil || !p.StartedAt.Equal(started) {+ t.Errorf("StartedAt = %v, want %v", p.StartedAt, started)+ }+ if p.Verified != nil {+ t.Errorf("Verified = %v, want nil: verification is not applicable yet", *p.Verified)+ }+ if inProgress, _ := p.Details["inProgress"].(bool); !inProgress {+ t.Error("Details[inProgress] = false, want true")+ }+}++func TestFromPVEStorageBackups_InProgressMapsToRunning(t *testing.T) {+ started := time.Date(2026, 8, 20, 9, 39, 1, 0, time.UTC)+ backups := []models.StorageBackup{+ {+ ID: "pve-pc-local:backup/vzdump-qemu-117.vma.zst",+ Instance: "pve-pc",+ Node: "pve-pc",+ Type: "qemu",+ VMID: 117,+ Time: started,+ Size: 7 << 30,+ Storage: "local",+ // Partial archive a running vzdump task is still writing.+ InProgress: true,+ },+ }++ result := FromPVEStorageBackups(backups, nil)+ if len(result) != 1 {+ t.Fatalf("expected 1 point, got %d", len(result))+ }++ p := result[0]+ if p.Outcome != recovery.OutcomeRunning {+ t.Errorf("Outcome = %v, want %v", p.Outcome, recovery.OutcomeRunning)+ }+ if p.CompletedAt != nil {+ t.Errorf("CompletedAt = %v, want nil for a running backup", p.CompletedAt)+ }+ if p.Verified != nil {+ t.Errorf("Verified = %v, want nil for a running backup", *p.Verified)+ }+}diff --git a/internal/unifiedresources/adapters.go b/internal/unifiedresources/adapters.goindex 1af718cebe..209971e603 100644--- a/internal/unifiedresources/adapters.go+++ b/internal/unifiedresources/adapters.go@@ -1759,6 +1759,7 @@ func resourceFromVM(vm models.VM) (Resource, ResourceIdentity) {Uptime: vm.Uptime,Template: vm.Template,LastBackup: vm.LastBackup,+ BackupInProgress: vm.BackupInProgress,DiskStatusReason: vm.DiskStatusReason,GuestAgentStatus: vm.GuestAgentStatus,GuestAgentExpected: vm.GuestAgentExpected,@@ -1829,6 +1830,7 @@ func resourceFromContainer(ct models.Container) (Resource, ResourceIdentity) {Uptime: ct.Uptime,Template: ct.Template,LastBackup: ct.LastBackup,+ BackupInProgress: ct.BackupInProgress,OSName: ct.OSName,NetworkInterfaces: convertGuestInterfaces(ct.NetworkInterfaces),OSTemplate: ct.OSTemplate,diff --git a/internal/unifiedresources/registry.go b/internal/unifiedresources/registry.goindex f546376ac3..90c9b6877d 100644--- a/internal/unifiedresources/registry.go+++ b/internal/unifiedresources/registry.go@@ -3642,6 +3642,10 @@ func mergeProxmoxData(existing *ProxmoxData, incoming *ProxmoxData) *ProxmoxDataif !incoming.LastBackup.IsZero() {merged.LastBackup = incoming.LastBackup}+ // A Proxmox facet is always built whole from the guest record, so the+ // backup-running flag is authoritative in both directions: it must set+ // when a backup starts and clear when it completes or aborts.+ merged.BackupInProgress = incoming.BackupInProgressif incoming.CPUInfo != nil {cpuInfo := *incoming.CPUInfomerged.CPUInfo = &cpuInfodiff --git a/internal/unifiedresources/types.go b/internal/unifiedresources/types.goindex 241cc2a52d..f93f5f45ae 100644--- a/internal/unifiedresources/types.go+++ b/internal/unifiedresources/types.go@@ -372,6 +372,7 @@ type ProxmoxData struct {KernelVersion string `json:"kernelVersion,omitempty"`Uptime int64 `json:"uptime,omitempty"`LastBackup time.Time `json:"lastBackup,omitempty"`+ BackupInProgress bool `json:"backupInProgress,omitempty"`DiskStatusReason string `json:"diskStatusReason,omitempty"`GuestAgentStatus string `json:"guestAgentStatus,omitempty"`GuestAgentExpected bool `json:"guestAgentExpected,omitempty"`diff --git a/internal/unifiedresources/views.go b/internal/unifiedresources/views.goindex ff58e254e3..43f90fd446 100644--- a/internal/unifiedresources/views.go+++ b/internal/unifiedresources/views.go@@ -186,6 +186,13 @@ func (v VMView) LastBackup() time.Time {return v.r.Proxmox.LastBackup}+func (v VMView) BackupInProgress() bool {+ if v.r == nil || v.r.Proxmox == nil {+ return false+ }+ return v.r.Proxmox.BackupInProgress+}+func (v VMView) DiskStatusReason() string {if v.r == nil || v.r.Proxmox == nil {return ""@@ -482,6 +489,13 @@ func (v ContainerView) LastBackup() time.Time {return v.r.Proxmox.LastBackup}+func (v ContainerView) BackupInProgress() bool {+ if v.r == nil || v.r.Proxmox == nil {+ return false+ }+ return v.r.Proxmox.BackupInProgress+}+func (v ContainerView) OSName() string {if v.r == nil || v.r.Proxmox == nil {return ""