Standard-Machine: UDC backup/restore use ArchivedData (not ArchiveData)

UDC's per-bay archive directory is C:\ProgramData\UDC\ArchivedData, not
ArchiveData. The previous spelling was a typo introduced when the scripts
were first written; it would have meant Backup-UDCData.ps1 found no archive
content (silent zero-file backups), and Restore-UDCData.ps1 wrote into a
location UDC does not read from.

Path swap is straight string replacement across both scripts plus the .bat
wrapper's usage comment. Manifest field names in backup.manifest.json /
restore.manifest.json (ArchivedDataPresent, ArchivedDataFiles,
ArchivedDataBytes) updated to match.

Update-MachineNumber.ps1's parallel UDC-restore branch (still uncommitted
in a prior workstream) has the same fix in the working tree, captured in
that branch's eventual commit.

The v2 share-staged copy at tsgwp00525-v2\standard-machine\scripts\
Restore-UDCData.ps1 also got the fix and is ready for push.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-04-29 11:45:39 -04:00
parent 0badfc1983
commit e169f8d0f5
3 changed files with 22 additions and 22 deletions

View File

@@ -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 <bay>\migrated\<timestamp>\, 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