2025-02-06

Synology Active Backup for Business for Hyper-V VM Failed to Backup #02

繼前一篇  Synology Active Backup for Business for Hyper-V VM Failed to Backup #01
取得 Patch 跳過了 5 個 Snapshots 的問題後

還是備份失敗

於是再用 Support Center App 產生 Active Backup for Business 的 Debug Log 後
在 ActiveBackup\volume1\@ActiveBackup\log\vm.log 中看到

synoabk_vm_backup[6175]: synoabk_vm::[WARNING] hyperv_agent.cpp:1381(6175,139923524343360) [6175]hypervisor_agent/hyperv_agent.cpp:145 {"error_class":"PowerShellException","error_message":"Missing an argument for parameter 'Id'. Specify a parameter of type 'System.Int32[]' and try again.","error_params":{"Activity":"Stop-Process","Category":5,"Reason":"ParameterBindingException","TargetName":"","TargetType":"","error_id":"MissingArgument,Microsoft.PowerShell.Commands.StopProcessCommand"},"success":false}

難道是 Powershell 語法錯誤少帶一個參數?

繼續又看到

synoabk_vm_backup[6175]: synoabk_vm::[ERROR] hyperv_disk.cpp:74(6175,139923524343360) Connect to HyperV disk server failed. [No such file or directory], sock[/run/synoabk/virtual_disk_server_6175.sock]

synoabk_vm_backup[6175]: synoabk_vm::[WARNING] hyperv_agent.cpp:1386(6175,139923524343360) [6175]virtual_disk/hyperv_disk.cpp:75 HyperV Message: null

以及
%UserProfile%\AppData\Local\ActiveBackup\**Some GUID**\2.6.0-0025\hyperv_helper.exe
看來 Active Backup for Business 也並非完全 Agent Less 嘛...

好了,CBT 失敗我並沒有那麼在意,那個等能成功備份之後再檢查就好
這時我在 Hyper-V Host 看到了一狗票錯誤訊息

莫非就是那個 hyperv_helper.exe ?

於是我到 Microsoft Security Virus & threat protection 把那個程式加為例外 (Exclusions)
雖然說他的路徑有一個 GUID 讓我覺得好像路徑會每次都不一樣有點擔心
但先加例外測試成功了再來煩惱不遲

於是開始測試,果然不需要擔心煩惱,因為還是備份失敗

好吧,那個 Action blocked 的細節到底要去哪裡看呢?
原來在 Event Log 的以下位置:

Applications and Services Logs -> Microsoft -> Windows -> Widnows Defender -> Operational

那把 C:\Windows\System32\wbem\WmiPrvSE.exe 也加入 Microsoft Security Virus & threat protection 的 Exclusions 試試看


結果就成功完成備份了,這是哪招?
原來是我在測試期間直接把 Real-time protection 關掉了這招


但是當時我沒有留意到是因為自己開了大絕招所以成功
成功完成備份後,我把那個 hyperv_helper.exe 從例外清單中移除
只保留 C:\Windows\System32\wbem\WmiPrvSE.exe  一個
也是能成功完成備份 ==> 當然可以,因為開了大絕招
結果後續過程中無意間將 Defender 等各種保護再開啟後就又備份失敗了 (心累)

因為我有用 GPO 派送 Windows Defender Antivirus 的政策,所以去檢查 GPO
在這裡看到了一個熟悉的字眼: Microsoft Defender Exploit Guard
就是在 Event Log 敘述開頭指出的元兇
並且在下方看到了 Attack Surface Reduction 裡面有 Exclude files and paths from Attack Surface Reduction (ASR) rules.


Add-MpPreference 指令的說明中有提到三個參數:
-AttackSurfaceReductionOnlyExclusions
-AttackSurfaceReductionRules_Actions
-AttackSurfaceReductionRules_Ids
順手將前面 Event Log 訊息裡的 ID: D1E49AAC-8F56-4280-B9BA-993A6D77406C Google 了一下
這篇文章中查到了該 ID 表示 Block process creations originating from PSExec and WMI commands
這下應該終於找到 Root Cause 了吧!
應該要把程式加到 ASR (AttackSurfaceReductionOnlyExclusions) 的例外清單
而不是 Windows Defender Antivirus 的例外清單
但是這個例外清單在 Microsoft Security Settings 的 GUI 介面中沒得設定!
GUI 介面中也沒有出現任何 Exploit Guard 的字樣,難怪前面除錯的過程中完全不順利

有鑑於手動加例外清單這件事情容易出錯、忘記
或是那個 GUID 可能會變 (?) 等等因素,所以寫了下面的 PowerShell
如果有多台 Hyper-V Host 也可以用上述 GPO 派送的方式進行
(GPO Path: Computer Configuration/Administrative Templates/Windows Components/Microsoft Defender Antivirus/Microsoft Defender Exploit Guard/Attack Surface Reduction/Exclude files and paths from Attack Surface Reduction Rules)

$UserProfilePaths = @();
$Exclusions = @();
$ExclusionsExisted = @();
$ExclusionsExisted += ((Get-MpPreference).AttackSurfaceReductionOnlyExclusions);
$UserProfilePaths += ((Get-WMIObject -ClassName Win32_UserProfile -Filter "Special = False").LocalPath);
$HyperVHelperHit = $False;
foreach ($UserProfilePath in $UserProfilePaths) {
$ABBPath = ($UserProfilePath + '\AppData\Local\ActiveBackup');
if ((Test-Path -LiteralPath $ABBPath) -eq $True) {
$HyperVHelperHit = $True;
$ABBHelpers = @();
$ABBHelpers += ((Get-ChildItem -LiteralPath $ABBPath -Recurse) | where {$_.Extension -eq '.exe'});
if ($ABBHelpers.Count -gt 0) {
foreach ($ABBHelper in $ABBHelpers) {
if ($ExclusionsExisted -NotContains $ABBHelper.FullName) {
$Exclusions += $ABBHelper.FullName;
} else {
$Exclusions = ($Exclusions | where {$_ -ne $ABBHelper.FullName});
};
};
};
};
};
if ($HyperVHelperHit -eq $True) {
$WmiPrvSE_FullName = ($env:SystemRoot+'\'+'System32\wbem\WmiPrvSE.exe');
if ($ExclusionsExisted -NotContains $WmiPrvSE_FullName) {
$Exclusions += $WmiPrvSE_FullName;
} else {
$Exclusions = ($Exclusions | where {$_ -ne $WmiPrvSE_FullName});
};
};
if ($Exclusions.Count -gt 0) {
foreach ($Exclusion in $Exclusions) {
write-host ('Add "' + $Exclusion + '" as Exclusion to Microsoft Security Virus & Threat Protection');
Add-MpPreference -AttackSurfaceReductionOnlyExclusions $Exclusion
};
};

至此暫時是能進行備份作業了,後續再觀察看看
Synology 的技術支援工程師回覆我說:

hyperv_helper.exe 是 ABB 備份過程放到目標機器上協助執行備份任務的程式。
ABB 會需要透過 hyperv_helper.exe 在備份任務的過程做兩件事:

  1. 計算 CBT 回報給 ABB
  2. 讀取目標虛擬機的虛擬硬碟資料,傳遞給 ABB 儲存

之前沒有碰到此問題,是因為備份任務在執行到上述兩事項之前就因為 snapshot limit 問題而中止了。
因此需要請您協助將該程式加入防毒程式的例外清單內以避免防毒軟體誤判導致備份異常。


沒有留言:

張貼留言