fix: properly identify VMID 0 PBS backups as Host type instead of LXC (addresses #359)

PMG host configuration backups (VMID=0) are now correctly shown as "Host" type
in the backup list instead of being incorrectly labeled as "LXC" containers.
Also added mock data for testing VMID 0 host backups.
This commit is contained in:
Pulse Monitor
2025-09-04 13:36:40 +00:00
parent dae05e5975
commit fcb71daaea
2 changed files with 40 additions and 5 deletions
@@ -197,11 +197,22 @@ const UnifiedBackups: Component = () => {
return file.crypt || file.encrypted || (file.filename && file.filename.includes('.enc'));
});
// Determine the display type based on VMID and backup type
// VMID 0 = host config backup (e.g. PMG)
let displayType: GuestType;
if (parseInt(backup.vmid) === 0) {
displayType = 'Host';
} else if (backup.backupType === 'vm' || backup.backupType === 'VM') {
displayType = 'VM';
} else {
displayType = 'LXC';
}
unified.push({
backupType: 'remote',
vmid: parseInt(backup.vmid) || 0,
name: backup.comment || '',
type: (backup.backupType === 'vm' || backup.backupType === 'VM') ? 'VM' : 'LXC',
type: displayType,
node: backup.instance || 'PBS',
backupTime: backupTimeSeconds,
backupName: backupName,
@@ -242,14 +253,14 @@ const UnifiedBackups: Component = () => {
}
}
// Determine the display type based on backup.type
// Determine the display type based on backup.type and VMID
let displayType: GuestType;
if (backup.type === 'qemu') {
if (backup.vmid === 0 || backup.type === 'host') {
displayType = 'Host'; // PMG/PVE host config backups (VMID 0)
} else if (backup.type === 'qemu') {
displayType = 'VM';
} else if (backup.type === 'lxc') {
displayType = 'LXC';
} else if (backup.type === 'host') {
displayType = 'Host'; // PMG host config backups
} else {
displayType = 'LXC'; // Default fallback (most people have more containers than VMs)
}
+24
View File
@@ -1028,6 +1028,30 @@ func generatePBSBackups(vms []models.VM, containers []models.Container) []models
}
}
// Generate host config backups (VMID 0) - PMG/PVE host configs
// These are common when backing up Proxmox Mail Gateway hosts
hostBackupCount := 2 + rand.Intn(3) // 2-4 host backups
for i := 0; i < hostBackupCount; i++ {
backupTime := time.Now().Add(-time.Duration(rand.Intn(30*24)) * time.Hour)
backup := models.PBSBackup{
ID: fmt.Sprintf("pbs-backup-host-0-%d", i),
Instance: pbsInstances[rand.Intn(len(pbsInstances))],
Datastore: datastores[rand.Intn(len(datastores))],
Namespace: "root",
BackupType: "ct", // Host configs are stored as 'ct' type in PBS
VMID: "0", // VMID 0 indicates host config
BackupTime: backupTime,
Size: int64(50*1024*1024 + rand.Int63n(100*1024*1024)), // 50-150MB for host configs
Protected: rand.Float64() > 0.7, // 30% protected
Verified: rand.Float64() > 0.1, // 90% verified
Comment: "PMG host configuration backup",
Owner: "root@pam",
}
backups = append(backups, backup)
}
// Sort by time (newest first)
sort.Slice(backups, func(i, j int) bool {
return backups[i].BackupTime.After(backups[j].BackupTime)