News about scripting Veeam SureBackup with PowerShell
This post is about new possibilities in Veeam Backup&Replication (VBR) for scripting SureBackup jobs with PowerShell. These new features are available since v10 and will get important enhancements in v11.
What is it about
VBR SureBackup is a widely used important feature. It enables you to verify your backups by starting VMs out of your repository and perform tests. Depending on their results you decide if backup was okay or not. These tasks are fully automated.
So why should you use PowerShell for automation? Because managing SureBackup for a lot of VMs (several hundreds) do not scale very well in VBR console. There are scripts out there that can be used to handle SureBackup for a lot of VMs. One example is the script of Luca Dell’Oca.
When creating or changing SureBackup settings using the Veeam PowerShell Snapin, not all options were provided by the Snapin. For example startup timeout could not be set by PowerShell. Fortunately this is possible since v10-Snapin. Therefore new cmdlets were introduced: New-VBRSureBackupStartupOptions, New-VBRSureBackupVM, Add-VBRViApplicationGroup. See parameters in New-VBRSureBackupStartupOptions
here:
Existing cmdlet Add-VSBViApplicationGroup is now deprecated and will be marked as obsolete in the future. Luca also uses this old cmdlet.
How to use new commands
With new cmdlets it is possible to set – next to others – higher timeouts for boot initialization for SureBackup application groups. See here how to use them.
First, set your preferred option. See an example here:
$Startup = New-VBRSureBackupStartupOptions -AllocatedMemory 100 -EnableVMHeartbeatCheck:$true -EnableVMPingCheck:$false -MaximumBootTime 1000 -ApplicationInitializationTimeout 1000
Then, select the job(s) you want add VM to SureBackup from.
$VBRJob = Get-VBRJob -Name "Backup Job"
$VBRVMs = Get-VBRJobObject -Job $VBRJob
Now, build an array of backup-VMs of the correct object-type (CObjectInJob
, which comes from Get-VBRJobObject), New-VBRSureBackupVM
needs:
$VSBVMs = @()
$VBRVMs | foreach {$VSBVMs += New-VBRSureBackupVM -VM $_ -StartupOptions $Startup}
Finally, create your application group with the previous created array:
Add-VBRViApplicationGroup -Name "Autmated_group" -VM $VSBVMs
Here we are:
So far so good, BUT …
Currently there seems to be no way to use this, when VMs are selected by vSphere tags for backup! I ask already in the R&D Forum.
But the good news are: This works in PowerShell modules for v11. Here we can use New-VBRSureBackupVM
to add vSphere tags as well:
$AllVMs = New-VBRSureBackupVM -Tag $VBRVMs -StartupOptions $Startup
Notes
- Get your Trial of VBR.
- Backup job must have run at least once, bevor running
Get-VBRJobObject
. Otherwise you get the error:
[New-VBRSureBackupVM : Object reference not set to an instance of an object.]
- To verify which Veeam jobs were running at a point or interval in time, you can use this script.