Backup-UDCData.bat / Backup-UDCData.ps1: tech-runnable, UAC-self-elevating. Run on the OLD PC before retirement; reads bay number from udc_settings.json, copies CurrentData.json + ArchiveData/ to \\tsgwp00525\...\backup\udc\<bay>\, drops backup.manifest.json. Refuses the 9999 placeholder so backups never collide across PCs. Restore-UDCData.ps1: idempotent, designed for the manifest engine. 99% of cycles silent no-op (sub-second, zero side effects); 1% (cycle after a backup lands at this PC's bay) restores files locally, moves consumed backup to <bay>\migrated\<timestamp>\, writes restore.manifest.json, relaunches UDC. Round-trip + no-op fast path verified end-to-end on the win11 analyzer VM. Already wired into the Standard-Machine GE-Enforce manifest at standard-machine\manifest.json on the v2 share. Complementary to the placeholder-to-real branch in Update-MachineNumber.ps1: that branch covers the 9999 -> real flow, this one covers the pre-imaged-then-swapped flow where Update-MachineNumber already ran before any backup existed. Both safely no-op if the other consumed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.6 KiB
Batchfile
48 lines
1.6 KiB
Batchfile
@echo off
|
|
REM Backup-UDCData.bat - Tech-runnable wrapper for Backup-UDCData.ps1.
|
|
REM
|
|
REM Self-elevates via UAC so the script can read C:\ProgramData\UDC\* and
|
|
REM write to the SFLD share with the right cached creds. Forwards any
|
|
REM extra args verbatim (e.g. -KeepPriorBackup, -MachineNumber 7605).
|
|
REM
|
|
REM Usage on the OLD PC, before retirement:
|
|
REM 1. Double-click Backup-UDCData.bat (or right-click -> Run as admin)
|
|
REM 2. Approve the UAC prompt
|
|
REM 3. Watch the elevated PS window for the success summary
|
|
REM 4. Confirm \\tsgwp00525.wjs.geaerospace.net\shared\dt\shopfloor\backup\udc\<machine>\
|
|
REM now contains CurrentData.json + ArchiveData\ + backup.manifest.json
|
|
|
|
REM --- Self-elevate ---------------------------------------------------
|
|
net session >nul 2>&1
|
|
if %errorLevel% neq 0 (
|
|
echo Requesting admin rights...
|
|
powershell -Command "Start-Process '%~f0' -Verb RunAs -ArgumentList '%*'"
|
|
exit /b
|
|
)
|
|
|
|
set "SCRIPT=%~dp0Backup-UDCData.ps1"
|
|
|
|
if not exist "%SCRIPT%" (
|
|
echo ERROR: %SCRIPT% not found.
|
|
echo This .bat must be in the same folder as Backup-UDCData.ps1.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo ============================================================
|
|
echo UDC Data Backup
|
|
echo ============================================================
|
|
echo Script: %SCRIPT%
|
|
echo.
|
|
|
|
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT%" %*
|
|
set RC=%errorLevel%
|
|
|
|
echo.
|
|
echo ============================================================
|
|
echo Backup script exit code: %RC%
|
|
echo ============================================================
|
|
echo.
|
|
pause
|
|
exit /b %RC%
|