哦,我有一臺服務器將資料備份到 NAS,然后我從源 NAS 復制到目標 NAS。
我正在尋找一種方法來驗證已發送到目標 NAS 的大小數量是否與源 NAS 上的大小數量匹配。
因為移動資料量很大,無法一一查看。
有沒有人對我的問題有任何建議和解決方案?
謝謝
uj5u.com熱心網友回復:
如果您需要驗證在 2 個目錄之間復制的資料,我認為最好的選擇是比較檔案哈希而不是檔案大小。
您可以使用以下腳本來識別不一致的檔案
$Dir1 = "D:\SRC"
$Dir2 = "D:\DST"
$Dir1Hash = Get-ChildItem $Dir1 -recurse -file | Get-FileHash | select hash,Path,@{n='RemotePath';e={$_.path.replace($Dir1,$Dir2)}}
$Dir2Hash = Get-ChildItem $Dir2 -recurse -File | Get-FileHash | select hash,Path,@{n='RemotePath';e={$_.path.replace($Dir2,$Dir1)}}
foreach ($item in $Dir1Hash){
$ReplicaFile = $Dir2Hash | where {$_.RemotePath -eq $item.path}
if ($ReplicaFile) {
if ($item.Hash -ne $ReplicaFile.Hash){
Write-host "Incorrect hash of file: $($item.Path) on Replica folder" -ForegroundColor Cyan
}
}
else {
Write-Output "File: $($item.Path) doesn't exist on Replica Folder"
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/394614.html
