CMM: Backup-CMM also captures the whole C:\Program Files\WAI tree

Adds a wai_backup_<PC>_<ts>.zip (robocopy /E of C:\Program Files\WAI + the x86
path) alongside the goCMM + PC-DMIS backups, indexed in cmm-backup-index.json.
Captures machine/controller content beyond the per-version PC-DMIS grab. Can be
multi-GB if WAI holds the full PC-DMIS 2016 install.

NOTE: this only CAPTURES it. sync-cmm-backups.sh + Restore-CMM still handle only
gocmm/pcdmis zips - staging/restoring the WAI zip needs those updated too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-06-19 10:40:01 -04:00
parent 48bc609eb5
commit 2461804fc8

View File

@@ -63,6 +63,30 @@ foreach ($s in 'Backup-goCMMSettings.ps1','Backup-PCDMISSettings.ps1') {
catch { Log " ERROR in $s : $($_.Exception.Message)" }
}
# --- C:\Program Files\WAI (+ x86): whole vendor tree, captured complete.
# Holds machine/controller content beyond what the per-version PC-DMIS backup
# grabs. NOTE: can be multi-GB if WAI contains the full PC-DMIS 2016 install. ---
$waiRoots = @("$env:ProgramFiles\WAI", "${env:ProgramFiles(x86)}\WAI")
$waiPresent = @($waiRoots | Where-Object { Test-Path $_ })
if ($waiPresent.Count -gt 0) {
Log "---- capturing WAI tree (whole) ----"
$waiStage = Join-Path $env:TEMP "wai-bk-$ts"
New-Item -ItemType Directory -Path $waiStage -Force | Out-Null
foreach ($wr in $waiPresent) {
$label = if ($wr -like '*(x86)*') { 'WAI-x86' } else { 'WAI' }
robocopy $wr (Join-Path $waiStage $label) /E /R:1 /W:1 /NFL /NDL /NJH /NJS | Out-Null
Log " copied $wr -> $label"
}
$waiZip = Join-Path $dest "wai_backup_${env:COMPUTERNAME}_$ts.zip"
if (Test-Path $waiZip) { Remove-Item $waiZip -Force }
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory($waiStage, $waiZip)
Remove-Item $waiStage -Recurse -Force -EA SilentlyContinue
Log " WAI backup: $waiZip ($([math]::Round((Get-Item $waiZip).Length/1MB)) MB)"
} else {
Log "No C:\Program Files\WAI (or x86) - skipping WAI backup"
}
# index of what we captured
$zips = Get-ChildItem $dest -Filter '*.zip' -File -ErrorAction SilentlyContinue
[pscustomobject]@{
@@ -71,6 +95,7 @@ $zips = Get-ChildItem $dest -Filter '*.zip' -File -ErrorAction SilentlyContinue
Timestamp = (Get-Date -Format o)
goCMM = @($zips | Where-Object { $_.Name -like 'gocmm_backup_*' } | Select-Object -Expand Name)
PCDMIS = @($zips | Where-Object { $_.Name -like 'pcdmis_backup_*' } | Select-Object -Expand Name)
WAI = @($zips | Where-Object { $_.Name -like 'wai_backup_*' } | Select-Object -Expand Name)
} | ConvertTo-Json | Out-File (Join-Path $dest 'cmm-backup-index.json') -Encoding ascii
Log "================ DONE ================"