2

I'm trying to set up a script to run the backups of my Virtual Machines only using WBADMIN, I've got as fas as being able to backup all the VMs using the new -HyperV switch, however I also want to backup the HyperV Host Component. Does anyone have any experience in doing this or can point me to some documentation (the Microsoft one neglects this new -HyperV switch)

This is my powershell script if your interested:

#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
2
  • Good question. I see the gui choice, but nothing yet related to wbadmin cli.
    – TheCleaner
    May 23, 2013 at 13:15
  • Ok so I've found some actual microsoft documentation on this but it still doesn't mention the 'host component'. While its not the end of the world as all of my hosts are identical it would be easier to be able to restore it if required! blogs.msdn.com/b/virtual_pc_guy/archive/2013/02/25/…
    – Harrison
    May 30, 2013 at 19:13

2 Answers 2

1

So i finally figured out that you need to ditch WBADMIN and start using the WBbackup CMDLETS in powershell instead, heres how you can do it

#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    
0

Actually the solution is too easy to believe, and yes, it's nowhere documented. You actually "just" need to include the string "Host Component" in your VMlist (parameter --hyperv).

Just remember that it includes a space, and you thus you need to quote the string.

E.g. like that:

wbadmin start backup -backupTarget:$BackupPath -hyperv:"$VMList,Host Component" -quiet

At least with Windows Server 2016 this worked.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .