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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user