diff --git a/playbook/shopfloor-setup/Standard/Backup-UDCData.bat b/playbook/shopfloor-setup/Standard/Backup-UDCData.bat index 673f461..f404f2d 100644 --- a/playbook/shopfloor-setup/Standard/Backup-UDCData.bat +++ b/playbook/shopfloor-setup/Standard/Backup-UDCData.bat @@ -10,7 +10,7 @@ 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\\ -REM now contains CurrentData.json + ArchiveData\ + backup.manifest.json +REM now contains CurrentData.json + ArchivedData\ + backup.manifest.json REM --- Self-elevate --------------------------------------------------- net session >nul 2>&1 diff --git a/playbook/shopfloor-setup/Standard/Backup-UDCData.ps1 b/playbook/shopfloor-setup/Standard/Backup-UDCData.ps1 index bec50cb..feddb98 100644 --- a/playbook/shopfloor-setup/Standard/Backup-UDCData.ps1 +++ b/playbook/shopfloor-setup/Standard/Backup-UDCData.ps1 @@ -1,4 +1,4 @@ -# Backup-UDCData.ps1 - Capture UDC's CurrentData.json + ArchiveData/ to the +# Backup-UDCData.ps1 - Capture UDC's CurrentData.json + ArchivedData/ to the # SFLD share, keyed by the PC's current machine number. Runs LOCALLY on the # old PC before retirement; the new PC restores during its first # placeholder-to-real machine-number assignment via Update-MachineNumber.ps1. @@ -88,18 +88,18 @@ Log "Resolved machine number: $MachineNumber" # --- Verify source files exist --- $srcCurrent = Join-Path $UdcDataDir 'CurrentData.json' -$srcArchive = Join-Path $UdcDataDir 'ArchiveData' +$srcArchive = Join-Path $UdcDataDir 'ArchivedData' $haveCurrent = Test-Path -LiteralPath $srcCurrent $haveArchive = Test-Path -LiteralPath $srcArchive if (-not $haveCurrent -and -not $haveArchive) { - Log "Neither CurrentData.json nor ArchiveData/ exists under $UdcDataDir. Nothing to back up." 'WARN' + Log "Neither CurrentData.json nor ArchivedData/ exists under $UdcDataDir. Nothing to back up." 'WARN' try { Stop-Transcript | Out-Null } catch {} exit 0 } Log "CurrentData.json present: $haveCurrent" -Log "ArchiveData/ present: $haveArchive" +Log "ArchivedData/ present: $haveArchive" # --- Mount share if credentials supplied (otherwise rely on ambient auth) --- $psDrive = $null @@ -156,13 +156,13 @@ if ($haveCurrent) { } } -# --- Copy ArchiveData/ recursively --- +# --- Copy ArchivedData/ recursively --- $copiedArchive = $false $archiveBytes = 0 $archiveFiles = 0 if ($haveArchive) { try { - $destArchive = Join-Path $dest 'ArchiveData' + $destArchive = Join-Path $dest 'ArchivedData' if (Test-Path -LiteralPath $destArchive) { Remove-Item -LiteralPath $destArchive -Recurse -Force -ErrorAction Stop } @@ -171,9 +171,9 @@ if ($haveArchive) { $archiveItems = Get-ChildItem -LiteralPath $destArchive -Recurse -File -ErrorAction SilentlyContinue $archiveBytes = ($archiveItems | Measure-Object Length -Sum).Sum $archiveFiles = $archiveItems.Count - Log "Copied ArchiveData/ ($archiveFiles files, $archiveBytes bytes)" + Log "Copied ArchivedData/ ($archiveFiles files, $archiveBytes bytes)" } catch { - Log "Failed to copy ArchiveData/: $_" 'ERROR' + Log "Failed to copy ArchivedData/: $_" 'ERROR' } } @@ -186,9 +186,9 @@ try { MachineNumber = $MachineNumber CurrentDataPresent = $copiedCurrent CurrentDataBytes = $currentBytes - ArchiveDataPresent = $copiedArchive - ArchiveDataFiles = $archiveFiles - ArchiveDataBytes = $archiveBytes + ArchivedDataPresent = $copiedArchive + ArchivedDataFiles = $archiveFiles + ArchivedDataBytes = $archiveBytes } $manifest | ConvertTo-Json | Set-Content -Path (Join-Path $dest 'backup.manifest.json') -Encoding UTF8 Log "Wrote backup.manifest.json" @@ -206,7 +206,7 @@ Log "Backup complete:" Log " Bay: $MachineNumber" Log " Destination: $BackupShareRoot\$MachineNumber\" Log " CurrentData.json: $(if ($copiedCurrent) {'OK ('+$currentBytes+' bytes)'} else {'MISSING'})" -Log " ArchiveData/: $(if ($copiedArchive) {'OK ('+$archiveFiles+' files, '+$archiveBytes+' bytes)'} else {'MISSING'})" +Log " ArchivedData/: $(if ($copiedArchive) {'OK ('+$archiveFiles+' files, '+$archiveBytes+' bytes)'} else {'MISSING'})" Log "===============================================" try { Stop-Transcript | Out-Null } catch {} exit 0 diff --git a/playbook/shopfloor-setup/Standard/Restore-UDCData.ps1 b/playbook/shopfloor-setup/Standard/Restore-UDCData.ps1 index 4ca908b..4ce4a5c 100644 --- a/playbook/shopfloor-setup/Standard/Restore-UDCData.ps1 +++ b/playbook/shopfloor-setup/Standard/Restore-UDCData.ps1 @@ -8,7 +8,7 @@ # CONTRACT: # - 99% of cycles: no backup waiting -> exit 0 in ~1 second, no side effects # - 1 cycle (the one after Backup-UDCData lands a backup for this PC's bay): -# stop UDC, copy CurrentData.json + ArchiveData/ to C:\ProgramData\UDC, +# stop UDC, copy CurrentData.json + ArchivedData/ to C:\ProgramData\UDC, # move consumed backup to \migrated\\, write # restore.manifest.json, restart UDC. After this, root is empty so the # check returns "no backup waiting" again on subsequent cycles. @@ -71,7 +71,7 @@ if (-not $mn -or $mn -eq '9999' -or $mn -notmatch '^\d+$') { # --- Probe for a waiting backup --- $bayDir = Join-Path $BackupShareRoot $mn $srcCur = Join-Path $bayDir 'CurrentData.json' -$srcArc = Join-Path $bayDir 'ArchiveData' +$srcArc = Join-Path $bayDir 'ArchivedData' if (-not (Test-Path -LiteralPath $srcCur)) { # Most-common path: no backup waiting. Exit silently to keep enforce-cycle @@ -102,7 +102,7 @@ if (-not (Test-Path -LiteralPath $UdcDataDir)) { New-Item -ItemType Directory -Path $UdcDataDir -Force | Out-Null } $localCur = Join-Path $UdcDataDir 'CurrentData.json' -$localArc = Join-Path $UdcDataDir 'ArchiveData' +$localArc = Join-Path $UdcDataDir 'ArchivedData' # --- Copy CurrentData.json --- $copiedCur = $false @@ -114,7 +114,7 @@ try { Log "Copy CurrentData.json failed: $_" 'ERROR' } -# --- Copy ArchiveData/ --- +# --- Copy ArchivedData/ --- $copiedArc = $false $arcFiles = 0 $arcBytes = 0 @@ -128,9 +128,9 @@ if (Test-Path -LiteralPath $srcArc) { $arcFiles = $arcItems.Count $arcBytes = ($arcItems | Measure-Object Length -Sum).Sum $copiedArc = $true - Log "Copied ArchiveData/ ($arcFiles files, $arcBytes bytes)" + Log "Copied ArchivedData/ ($arcFiles files, $arcBytes bytes)" } catch { - Log "Copy ArchiveData/ failed: $_" 'ERROR' + Log "Copy ArchivedData/ failed: $_" 'ERROR' } } @@ -147,7 +147,7 @@ if ($consumeOk) { Move-Item -LiteralPath $srcCur -Destination (Join-Path $migStamp 'CurrentData.json') -Force -ErrorAction Stop if (Test-Path -LiteralPath $srcArc) { - Move-Item -LiteralPath $srcArc -Destination (Join-Path $migStamp 'ArchiveData') -Force -ErrorAction Stop + Move-Item -LiteralPath $srcArc -Destination (Join-Path $migStamp 'ArchivedData') -Force -ErrorAction Stop } $bakManifest = Join-Path $bayDir 'backup.manifest.json' if (Test-Path -LiteralPath $bakManifest) { @@ -160,8 +160,8 @@ if ($consumeOk) { DestinationUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name MachineNumber = $mn CurrentDataBytes = (Get-Item $localCur).Length - ArchiveDataFiles = $arcFiles - ArchiveDataBytes = $arcBytes + ArchivedDataFiles = $arcFiles + ArchivedDataBytes = $arcBytes RestoredVia = 'Restore-UDCData.ps1 (manifest engine, on logon)' } $restoreManifest | ConvertTo-Json | Set-Content -Path (Join-Path $migStamp 'restore.manifest.json') -Encoding UTF8