Wax/Trace: auto-restore captured backup ZIP during imaging
Wires the three pieces that make the per-bay backup restore happen as part of the PXE imaging pass, no manual post-imaging step required: 1. sync-waxtrace.sh: stage per-asset backup ZIPs from /home/camp/pxe-images/wt/<asset>/formtracepak_backup_*.zip (newest) into installers-post/waxtrace/backups/<asset>.zip on the PXE share. Also pushes scripts/Install-FormtracepakSettings.ps1 alongside the bootstrap bundle so 09-Setup can call it post-vendor-install. 2. startnet.cmd: after the FTPak ISO cherry-pick, xcopy Y:\installers-post\waxtrace\backups\%MACHINENUM%.zip to W:\WaxTrace-Install\backup\%MACHINENUM%.zip. Logs INFO if no per-asset ZIP exists - 09-Setup will then skip the restore step. 3. 09-Setup-WaxAndTrace.ps1 Step 3b: between cal ISO and OpenText auto-start steps, look for C:\WaxTrace-Install\backup\<asset>.zip and invoke Install-FormtracepakSettings.ps1 -BackupPath ... -RestoreData -RestoreConfig -Force. Registry restore is intentionally omitted - captured HKLM is overwritten by the vendor MSI install in Step 2 anyway, and captured HKEY_USERS would land at the source bay's SID (which doesn't exist on the freshly imaged bay). bay-config.csv refresh: 17 captured bays with full version/model/ user_id/hw_sn/hw_id/host. Versions stick to the original bay-config.csv target values where the live binary drifted to a release we don't have an ISO for (e.g. WJRP2035 live 5.7.0.82 -> imaging targets 6.0). WJF00450 flagged MISSING_DATA in user_id + hw_id columns so the imaging path aborts cleanly until the dongle is read. Smoke tested on win11 VM with WJF00545's real capture: staged the expected bay-side layout (C:\WaxTrace-Install\Install-FormtracepakSettings.ps1 + C:\WaxTrace-Install\backup\WJF00545.zip), invoked the resolve + call path from a simulated Step 3b - 17 files restored cleanly, 0 errors.
This commit is contained in:
@@ -318,6 +318,45 @@ if (-not $asset) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Step 3b: Restore captured layouts / prefs / data from per-asset backup ZIP
|
||||||
|
# ============================================================================
|
||||||
|
# startnet.cmd stages C:\WaxTrace-Install\backup\<asset>.zip iff the PXE
|
||||||
|
# share has a backup ZIP for this asset. The ZIP is the output of
|
||||||
|
# Backup-FormtracepakSettings.ps1 captured on the LIVE bay BEFORE re-imaging.
|
||||||
|
# Restore is data + config only - skip -RestoreRegistry until the HKEY_USERS
|
||||||
|
# SID rewriting is built (captured .reg carries source bay's user SID which
|
||||||
|
# does not exist on the freshly imaged bay). HKLM controller config / model
|
||||||
|
# device-map / etc. came from the vendor MSI install in Step 2 already.
|
||||||
|
$backupZip = $null
|
||||||
|
$backupDir = 'C:\WaxTrace-Install\backup'
|
||||||
|
if ($bayAsset -and (Test-Path -LiteralPath $backupDir)) {
|
||||||
|
$candidate = Join-Path $backupDir ("$bayAsset.zip")
|
||||||
|
if (Test-Path -LiteralPath $candidate) {
|
||||||
|
$backupZip = $candidate
|
||||||
|
} else {
|
||||||
|
$newest = Get-ChildItem -LiteralPath $backupDir -Filter "${bayAsset}*.zip" -File -ErrorAction SilentlyContinue |
|
||||||
|
Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
||||||
|
if ($newest) { $backupZip = $newest.FullName }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($backupZip) {
|
||||||
|
$installPs1 = Join-Path $stagingRoot 'Install-FormtracepakSettings.ps1'
|
||||||
|
if (Test-Path -LiteralPath $installPs1) {
|
||||||
|
Write-WTLog "Restoring per-asset backup from $backupZip"
|
||||||
|
try {
|
||||||
|
& $installPs1 -BackupPath $backupZip -RestoreData -RestoreConfig -Force
|
||||||
|
Write-WTLog " Restore call returned (see restore log + Install-FormtracepakSettings output above)"
|
||||||
|
} catch {
|
||||||
|
Write-WTLog " Restore call threw: $_" 'WARN'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-WTLog "Install-FormtracepakSettings.ps1 not found at $installPs1 - skipping restore" 'WARN'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-WTLog "No per-asset backup ZIP at $backupDir\$bayAsset.zip - skipping restore (clean vendor install only)"
|
||||||
|
}
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Step 4: OpenText auto-start at login (HostExplorer "WJ Shopfloor" session)
|
# Step 4: OpenText auto-start at login (HostExplorer "WJ Shopfloor" session)
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
asset_tag,ftpak_version,model,user_id
|
asset_tag,ftpak_version,model,user_id,hw_sn,hw_id,host,notes
|
||||||
WJF00159,6.103,AVANT,3974839712
|
WJF00052,6.103,CV-4500,3270314998,100032204,00039188,G2ZTNCX3ESF,bay-config was AVANT - corrected to CV-4500 per device-map
|
||||||
WJRP3689,5.510,CV-4500,3744284509
|
WJF00083,6.103,AVANT,2934506987,100062206,00039341,GDMT28Y3ESF,
|
||||||
WJRP2660,6.0,CV-4500,2365986521
|
WJF00084,6.103,AVANT,1476212857,100042205,00039348,G2GY4SY3ESF,
|
||||||
WJRP2659,6.0,CV-4500,2709054503
|
WJF00159,6.103,AVANT,3974839712,100072210,00040145,G5PRTW04ESF,
|
||||||
WJF00545,6.213,AVANT,3878777362
|
WJF00197,6.104,AVANT,1191612605,300022404,00041459,GHNWYRT3ESF,
|
||||||
WJRP3638,5.602,CV-4500,0720778210
|
WJF00450,6.204,AVANT,MISSING_DATA,400052411,MISSING_DATA,G8KRCPZ3ESF,DO NOT MIGRATE - user_id + hw_id need dongle read
|
||||||
WJF00052,6.103,AVANT,3270314998
|
WJF00461,6.213,AVANT,3878777362,400012504,00044757,G2PMG3D4ESF,new bay (was misattributed to WJF00545 in old CSV)
|
||||||
WJF00084,6.103,AVANT,1476212857
|
WJF00545,6.213,AVANT,3268459559,500022512,00045652,G6MJG3D4ESF,user_id refreshed 2026-05-24 (was 3878777362)
|
||||||
WJF00083,6.103,AVANT,2934506987
|
WJRP0423,6.0,CV-3100,3669340917,720104,00025834,GGDBWRT3ESF,old bay - device-map name 'NewCVSV' is Mitutoyo internal for CV-3100
|
||||||
WJRP3025,6.0,CV-3200,2292822471
|
WJRP2035,6.0,CV-4500,2292822471,200011406,0008232,G6W7JK44ESF,live binary is 5.7.0.82 - migrating to original 6.0 target
|
||||||
WJF00197,6.104,AVANT,1191612605
|
WJRP2335,6.0,CV-4500,1780916688,800011510,00011911,G4B48FZ3ESF,live binary is 5.7.0.82 - migrating to original 6.0 target
|
||||||
WJRP4802,6.002,AVANT,0920866935
|
WJRP2347,6.0,CV-4500,3585172946,800021510,00011674,GDR6B8B3ESF,live binary is 5.7.0.82 - migrating to original 6.0 target
|
||||||
WJRP2347,6.0,CV-4500,3585172946
|
WJRP2659,6.0,CV-4500,2709054503,000021608,00015700,G33N20R3ESF,live binary is 5.7.0.82 - migrating to original 6.0 target
|
||||||
WJRP2035,6.0,CV-4500,2292822471
|
WJRP2660,6.0,CV-4500,236598621,000011607,00015588,GGGMF1V3ESF,live binary is 5.7.0.92 - migrating to original 6.0 target
|
||||||
WJRP2335,6.0,CV-4500,1780916688
|
WJRP3638,5.602,CV-4500,0720778210,400031808,00024395,GFDBWRT3ESF,
|
||||||
|
WJRP3689,5.510,CV-4500,3744284509,400021807f,00024390,G4HCKF33ESF,live binary is 5.6.0.40 (release 5.602) - migrating to original 5.510 target
|
||||||
|
WJRP4802,6.002,AVANT,0920866935,100062108,00034683,G5W7R704ESF,live binary is 5.7.0.92 - migrating to original 6.002 target
|
||||||
|
|||||||
|
@@ -521,6 +521,20 @@ if not "%WTVER%"=="" (
|
|||||||
) else (
|
) else (
|
||||||
echo WARNING: bay-config did not resolve a FTPak version for %MACHINENUM%.
|
echo WARNING: bay-config did not resolve a FTPak version for %MACHINENUM%.
|
||||||
)
|
)
|
||||||
|
REM Cherry-pick the per-asset backup ZIP (captured from the live bay before
|
||||||
|
REM re-imaging) into W:\WaxTrace-Install\backup\<asset>.zip. sync-waxtrace.sh
|
||||||
|
REM stages one ZIP per asset under installers-post\waxtrace\backups\ named
|
||||||
|
REM <asset>.zip. 09-Setup-WaxAndTrace.ps1 reads it post-vendor-MSI and runs
|
||||||
|
REM Install-FormtracepakSettings.ps1 -RestoreData -RestoreConfig.
|
||||||
|
mkdir W:\WaxTrace-Install\backup 2>NUL
|
||||||
|
if not "%MACHINENUM%"=="" (
|
||||||
|
if exist "Y:\installers-post\waxtrace\backups\%MACHINENUM%.zip" (
|
||||||
|
xcopy /Y "Y:\installers-post\waxtrace\backups\%MACHINENUM%.zip" "W:\WaxTrace-Install\backup\"
|
||||||
|
echo Staged per-asset backup %MACHINENUM%.zip for restore.
|
||||||
|
) else (
|
||||||
|
echo INFO: No backup ZIP for %MACHINENUM% on share - 09-Setup will skip the restore step.
|
||||||
|
)
|
||||||
|
)
|
||||||
goto skip_waxtrace_stage
|
goto skip_waxtrace_stage
|
||||||
:skip_waxtrace_missing
|
:skip_waxtrace_missing
|
||||||
echo WARNING: Y:\installers-post\waxtrace not found - WaxTrace PC cannot install FormTracePak at imaging time.
|
echo WARNING: Y:\installers-post\waxtrace not found - WaxTrace PC cannot install FormTracePak at imaging time.
|
||||||
|
|||||||
@@ -74,6 +74,13 @@ fi
|
|||||||
if [ -f "$WAXTRACE_DIR/resolve-bay-config.ps1" ]; then
|
if [ -f "$WAXTRACE_DIR/resolve-bay-config.ps1" ]; then
|
||||||
cp "$WAXTRACE_DIR/resolve-bay-config.ps1" "$STAGE/"
|
cp "$WAXTRACE_DIR/resolve-bay-config.ps1" "$STAGE/"
|
||||||
fi
|
fi
|
||||||
|
# Install-FormtracepakSettings.ps1 - called from 09-Setup-WaxAndTrace.ps1
|
||||||
|
# Step 3b to restore captured layouts / prefs / data from the per-asset
|
||||||
|
# backup ZIP. Path on the bay post-startnet-xcopy:
|
||||||
|
# C:\WaxTrace-Install\Install-FormtracepakSettings.ps1.
|
||||||
|
if [ -f "$WAXTRACE_DIR/scripts/Install-FormtracepakSettings.ps1" ]; then
|
||||||
|
cp "$WAXTRACE_DIR/scripts/Install-FormtracepakSettings.ps1" "$STAGE/"
|
||||||
|
fi
|
||||||
cp "$WAXTRACE_DIR/captured-binary/prereqs/"*.exe "$STAGE/prereqs/"
|
cp "$WAXTRACE_DIR/captured-binary/prereqs/"*.exe "$STAGE/prereqs/"
|
||||||
|
|
||||||
# FormTracePak vendor installer ISOs - all available versions get pushed.
|
# FormTracePak vendor installer ISOs - all available versions get pushed.
|
||||||
@@ -99,11 +106,34 @@ if [ -d "$CAL_ISO_DIR" ]; then
|
|||||||
cp "$CAL_ISO_DIR/INDEX.csv" "$STAGE/calibrations/" 2>/dev/null || true
|
cp "$CAL_ISO_DIR/INDEX.csv" "$STAGE/calibrations/" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Per-asset FormTracePak backup ZIPs. The tech captures these on the live
|
||||||
|
# bays via Backup-FormtracepakSettings.bat (lands at
|
||||||
|
# S:\DT\Shopfloor\backup\waxandtrace\<asset>\formtracepak_backup_*.zip on
|
||||||
|
# tsgwp00525), then mirrors them down to /home/camp/pxe-images/wt/<asset>/
|
||||||
|
# on this Linux host. Pick the newest ZIP per asset and stage as
|
||||||
|
# <asset>.zip so startnet.cmd can cherry-pick a known filename per bay.
|
||||||
|
BACKUP_SRC_DIR="${WAXTRACE_BACKUP_DIR:-/home/camp/pxe-images/wt}"
|
||||||
|
mkdir -p "$STAGE/backups"
|
||||||
|
BACKUP_COUNT=0
|
||||||
|
if [ -d "$BACKUP_SRC_DIR" ]; then
|
||||||
|
for asset_dir in "$BACKUP_SRC_DIR"/WJ*/; do
|
||||||
|
[ -d "$asset_dir" ] || continue
|
||||||
|
asset=$(basename "$asset_dir")
|
||||||
|
newest=$(ls -1t "$asset_dir"/formtracepak_backup_*.zip 2>/dev/null | head -1)
|
||||||
|
if [ -n "$newest" ] && [ -s "$newest" ]; then
|
||||||
|
cp "$newest" "$STAGE/backups/${asset}.zip"
|
||||||
|
BACKUP_COUNT=$((BACKUP_COUNT+1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo "Staged $BACKUP_COUNT per-asset backup ZIP(s) from $BACKUP_SRC_DIR"
|
||||||
|
|
||||||
echo "==> Local stage size: $(du -sh $STAGE | cut -f1)"
|
echo "==> Local stage size: $(du -sh $STAGE | cut -f1)"
|
||||||
ls "$STAGE/"
|
ls "$STAGE/"
|
||||||
ls "$STAGE/prereqs/"
|
ls "$STAGE/prereqs/"
|
||||||
ls "$STAGE/formtracepak/" 2>/dev/null || echo "(no FormTracePak ISO)"
|
ls "$STAGE/formtracepak/" 2>/dev/null || echo "(no FormTracePak ISO)"
|
||||||
ls "$STAGE/calibrations/" 2>/dev/null || echo "(no cal ISOs)"
|
ls "$STAGE/calibrations/" 2>/dev/null || echo "(no cal ISOs)"
|
||||||
|
ls "$STAGE/backups/" 2>/dev/null || echo "(no per-asset backup ZIPs)"
|
||||||
|
|
||||||
echo "==> Pushing to $PXE_USER@$PXE_HOST:$REMOTE_TEMP"
|
echo "==> Pushing to $PXE_USER@$PXE_HOST:$REMOTE_TEMP"
|
||||||
ssh_run "rm -rf '$REMOTE_TEMP' && mkdir -p '$REMOTE_TEMP'"
|
ssh_run "rm -rf '$REMOTE_TEMP' && mkdir -p '$REMOTE_TEMP'"
|
||||||
|
|||||||
Reference in New Issue
Block a user