Files
flash-build/backup-flash-verify-2.ps1
T
2026-11-13 07:52:38 +03:00

64 lines
2.7 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Сверка бэкапа v2 с флешкой.
$dest = 'C:\PF\flash-backup-2026-10-30-2'
function Stat($p, $filter) {
$f = Get-ChildItem $p -Recurse -File -Force -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -notmatch '\\\$RECYCLE\.BIN\\|\\System Volume Information\\' } |
Where-Object { & $filter $_.FullName }
$m = $f | Measure-Object -Sum Length
return [pscustomobject]@{ Count = $m.Count; Sum = $m.Sum }
}
'--- сравнение объёмов:'
$checks = @(
@('F:', 'F:\', "$dest\01-PARAVIS-F", { param($p) $p -notlike 'F:\efi\Paravis\Linux\*' -and $p -ne "$dest\01-PARAVIS-F\efi\Paravis\Linux\_СОДЕРЖИМОЕ_НЕ_ВХОДИТ_В_БЭКАП.txt" }),
@('G:', 'G:\', "$dest\02-VTOYEFI-G", { param($p) $true }),
@('H:', 'H:\', "$dest\03-DATA-H", { param($p) $p -notlike '*.iso' })
)
foreach ($c in $checks) {
$src = Stat $c[1] $c[3]
$dst = Stat $c[2] $c[3]
$ok = ($src.Count -eq $dst.Count -and $src.Sum -eq $dst.Sum)
' {0} источник {1,5} файлов / {2,7:N0} байт бэкап {3,5} / {4,7:N0} {5}' -f `
$c[0], $src.Count, $src.Sum, $dst.Count, $dst.Sum, $(if ($ok) { 'OK' } else { 'РАСХОЖДЕНИЕ' })
}
'--- SHA-256 ключевых файлов:'
$key = @(
'efi\Paravis\Boot\grub2\grub.cfg',
'efi\Paravis\Boot\grub2\menu\utilits.cfg',
'efi\Paravis\Boot\super\x64.efi',
'efi\Paravis\Boot\super\x86.efi',
'efi\Paravis\Boot\super\super.iso',
'efi\Paravis\Boot\g4d\grldr',
'efi\Paravis\Boot\g4d\Ventoy',
'efi\Paravis\Boot\g4d\gfm',
'efi\Paravis\Boot\g4d\antiv',
'efi\Paravis\Boot\xor\xmbr.bin',
'efi\Paravis\Boot\bcd\bcd',
'efi\Paravis\KRD\live\vmlinuz',
'efi\Paravis\KRD\live\initrd.img',
'efi\Paravis\KRD\live\filesystem.squashfs',
'efi\Paravis\KRD\live\KRD\10-krd.srm',
'efi\Paravis\KRD\live\KRD\20-krt.srm',
'efi\Paravis\KRD\live\KRD\30-bases.srm',
'efi\Paravis\Utilities\ADD',
'efi\Paravis\Utilities\ABA',
'Change_bootLoader.exe'
)
$fail = 0
foreach ($k in $key) {
$a = Join-Path 'F:\' $k
$b = Join-Path "$dest\01-PARAVIS-F" $k
if (-not (Test-Path $a)) { ' {0,-52} нет на флешке' -f $k; continue }
if (-not (Test-Path $b)) { ' {0,-52} НЕТ В БЭКАПЕ' -f $k; $fail++; continue }
$h1 = (Get-FileHash $a -Algorithm SHA256).Hash
$h2 = (Get-FileHash $b -Algorithm SHA256).Hash
if ($h1 -ne $h2) { $fail++ }
' {0,-52} {1}' -f $k, $(if ($h1 -eq $h2) { 'OK ' + $h1.Substring(0,12) } else { 'РАСХОЖДЕНИЕ' })
}
''
'--- корень бэкапа:'
Get-ChildItem $dest -Force | Select-Object Mode,Name,Length | Format-Table -AutoSize
if ($fail -eq 0) { '=== ВСЁ СОВПАДАЕТ' } else { "=== РАСХОЖДЕНИЙ: $fail" }