Windows
如何使用 wbadmin 在備份中包含 HyperV 的“主機組件”?
我正在嘗試設置一個腳本來僅使用 WBADMIN 執行我的虛擬機的備份,我已經能夠使用新的 -HyperV 開關備份所有虛擬機,但是我也想備份 HyperV主機組件。有沒有人有這方面的經驗或者可以指點我一些文件(微軟忽略了這個新的 -HyperV 開關)
如果您有興趣,這是我的 powershell 腳本:
#Constant Variables $Day = Get-Date $Day = $Day.DayOfWeek $Date = Get-Date -format hhmmddMMyyyy $Server = hostname #Set Paths $BackupPath = "\\backup\Backups\" + $Server + "\" +$Day $LogPath = "\\backup\Backups\" + $Server + "\Logs\" + $Date +".txt" # SELECT Virtual Machines $VMList = $null $VMs = Get-VM | Select-Object VMId for ($i = 0 ; $i -lt $VMs.length ; $i++) { $VMList = $VMList + '"' + $VMs[$i].VMId + '"' +"," } $VMList = $VMList.Substring(0,$VMList.Length - 1) #Run Backup WBADMIN START BACKUP -backupTarget:$BackupPath -hyperv:$VMList -Quiet
所以我終於發現你需要放棄 WBADMIN 並開始在 powershell 中使用 WBbackup CMDLETS,這就是你如何做到的
#Constant Variables $Day = Get-Date #Use this for Backups in Evening $Day = ($Day.AddDays(1)).DayOfWeek #Use this for Backups in the Morning #$Day = $Day.DayOfWeek $Date = Get-Date -format hhmmddMMyyyy $Server = hostname $Target = '\\backup\backups\'+$Server+'\'+$Day $VirtualMachines = Get-WBVirtualMachine $DailyFullWB = New-WBPolicy $BackupTarget = New-WBBackupTarget -NetworkPath $Target Set-WBPolicy -Policy $DailyFullWB Add-WBBackupTarget -Policy $DailyFullWB -Target $BackupTarget -Force Add-WBVirtualMachine -Policy $DailyFullWB -VirtualMachine $VirtualMachines Start-WBBackup -Policy $DailyFullWB -AllowDeleteOldBackups -Force