CMM: wire per-bay settings restore into the imaging flow

Restore-CMM.ps1 (new) restores a CMM's PC-DMIS + goCMM settings at imaging from
its staged backup. Self-gating: reads C:\Enrollment\cmm\{cmmid,version,doda,
partgroup}.txt, skips DODA bays and bays with no staged backup, and restores
ONLY the config-version PC-DMIS zip via the existing Install-*Settings scripts.
Same-bay restore (cmmid match) so the backed-up controller CommPort is this
bay's own value - no cross-bay clobber.

Version selection matches the VERSION FIELD of the zip name, anchored on the
trailing timestamp, so version=2026 does not false-match a 2019/2016 zip whose
backup timestamp (20260612...) merely contains "2026".

09-Setup-CMM.ps1: new Step 2.8 calls Restore-CMM after app install + first-run
init (so a restored config is not clobbered by PC-DMIS defaults) and before the
C:\CMM-Install cleanup (the backup set lives under <stagingRoot>\backups\<cmmid>).
Best-effort: Restore-CMM always exits 0, imaging never fails on a restore.

startnet.cmd: stage ONLY the picked bay's backup into C:\CMM-Install\backups\
%CMMID% (the bulk robocopy now /XD-excludes the backups tree, which holds every
bay's backup - some 240 MB each - to avoid copying GBs to every imaged CMM).
Also bump the PPKG to v4.16 (the live boot.wim was already v4.16; the repo had
drifted to v4.14).

sync-cmm-backups.sh: source the backups from pxe-images/cmm/backups (where
Backup-CMM writes via the pulled-down copies), not the old cmm-bk path.

Smoke tested on the win11 VM against CMM3's real backup: version=2019 restored
the 2019 R2 zip (not 2016.0), imported HKLM+HKCU reg, converted the part-group
S:\ path to the tsgwp00525 UNC, created C:\geaofi, exit 0; version=2026 correctly
found no matching zip (anchor works).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-06-12 15:34:10 -04:00
parent 59deaea714
commit c2538a05c5
4 changed files with 145 additions and 5 deletions

View File

@@ -321,6 +321,28 @@ if (Test-Path $goCmmKey) {
}
}
# ============================================================================
# Step 2.8: Restore this bay's PC-DMIS + goCMM settings from its backup
# ============================================================================
# Runs AFTER app install + first-run-init (so a restored config is not clobbered
# by PC-DMIS's first-launch defaults) and BEFORE the Step 3 cleanup (the backup
# set lives under $stagingRoot\backups\<cmmid>, deleted by cleanup). Restore-CMM
# self-gates: it skips DODA bays and bays with no staged backup, and restores
# ONLY the config-version PC-DMIS zip. Same-bay restore -> no CommPort clobber.
# Best-effort: Restore-CMM always exits 0, so imaging never fails on a restore.
$restoreScript = Join-Path $PSScriptRoot 'scripts\Restore-CMM.ps1'
if (Test-Path -LiteralPath $restoreScript) {
Write-CMMLog "Running per-bay settings restore (Restore-CMM.ps1)"
try {
& $restoreScript -BackupRoot (Join-Path $stagingRoot 'backups') *>&1 | ForEach-Object { Write-CMMLog " $_" }
Write-CMMLog "Restore-CMM returned $LASTEXITCODE"
} catch {
Write-CMMLog "Restore-CMM threw (non-fatal): $_" 'WARN'
}
} else {
Write-CMMLog "Restore-CMM.ps1 not found at $restoreScript - skipping settings restore" 'WARN'
}
# ============================================================================
# Step 3: Conditional cleanup of the bootstrap staging dir
# ============================================================================