PowerShell script exchange
Post Reply
woifgaung
Veeam Software
Posts: 79
Liked: 22 times
Joined: Oct 15, 2015 2:57 pm
Full Name: Wolfgang Scheer
Contact:

Workaround for: Scripting SureBackup with tag-based backup jobs

Post by woifgaung » 1 person likes this post

I tried a lot to get the following to work: Scripting SureBackup with the possibility to set boot and application initialization timeout with PowerShell. Basically this can be done since v10. With this version there are new PowerShell cmdlets for SureBackup, I show later. The problem is, VM(s) to test must be added to SureBackup as an object you get with cmdlet Get-VBRJobObject which do not support tag-based VM selection.

The following forum posts deal with this limitation:
powershell-f26/scripting-surebackup-wit ... 75341.html
powershell-f26/case-04970788-change-sta ... 76190.html
powershell-f26/veeam-10-application-gro ... ml#p395366
veeam-backup-replication-f2/is-it-possi ... 76172.html

The good news: there is workaround for this! The idea is to add VM you want to test temporary to the backup job explicitly - Special thanks to @lessi001 who had the great idea! Then it is possible to add VM to SureBackup even the original job used tag-based VM selection. When this is done, VM can be removed from job again. Probably some script snippets will illustrate this better.

Set SureBackup startup options:

Code: Select all

$VbsStartOptions = New-VBRSureBackupStartupOptions -AllocatedMemory 100 -EnableVMHeartbeatCheck:$true -EnableVMPingCheck:$true -MaximumBootTime 900 -ApplicationInitializationTimeout 900 
To continue, you need the VM name and the backup job of your VM to test with SureBackup.

Code: Select all

$TestVMObject = Find-VBRViEntity -Name $TestVMname
$TestVMVbrJob = Get-VBRJob -Name $TestVMJobname
With this data you can add VM temporary to the job.

Code: Select all

Add-VBRViJobObject -Job $TestVMVbrJob -Entities $TestVMObject
Next, get this added VM as correct object for further processing. Here it is important to just select backup objects with type "Include". This is because when this VM is explicitly added to guest processing (for special configuration there), you would see this VM with type "Vsschild" which cannot be used here.

Code: Select all

$VbrJobObject = Get-VBRJobObject -Job $TestVMVbrJob -name $TestVMObject.Name | Where-Object {$_.type -eq "Include"}
This new object can now be combined with the startup options to create a SureBackup-VM object

Code: Select all

$SbVMs += New-VBRSureBackupVM -VM $VbrJobObject -StartupOptions $VbsStartOptions
After this command, VM can be removed form job again

Code: Select all

Remove-VBRJobObject -Objects $VbrJobObject -Completely
Now create the application group

Code: Select all

$AppGroup = Add-VBRViApplicationGroup -Name $AppGroupName -VM $SbVMs}
Because existing backup job is temporary changed, attention should be paid here! If VMs are added explicitly to selection of backup jobs, you should check before adding VM to the job. And just remove it if you really added it before!

When this post is interesting for you, you possibly working with the script from Luca Dell’Oca: https://www.virtualtothecore.com/can-te ... surebackup. Keep in mind, in order to use the described new commands you need the backup job as parameter. This was not necessary with the old ones. Because of this, Luca's script uses a hashtable with just VM name. i personally think it is a good idea to replace this hashtable by an array that includes the job name. Works at least fine for me.
Wolfgang | CEMEA Solutions Architect | vnote42.net
HannesK
Product Manager
Posts: 14844
Liked: 3086 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:

Re: Workaround for: Scripting SureBackup with tag-based backup jobs

Post by HannesK »

Hello Wolfgang,
thanks for sharing the workaround with the community. 👍

On the other hand, I also agree that there is room for improvement for SureBackup PowerShell support on our side. :-)

Thanks,
Hannes
woifgaung
Veeam Software
Posts: 79
Liked: 22 times
Joined: Oct 15, 2015 2:57 pm
Full Name: Wolfgang Scheer
Contact:

Re: Workaround for: Scripting SureBackup with tag-based backup jobs

Post by woifgaung »

Thanks Hannes, made with pleasure! Looking forward to improvements in this area!

Some feature I do miss in SureBackup is the ability to check a bunch VMs standardized, just like Luca Dell’Oca's script.
Wolfgang | CEMEA Solutions Architect | vnote42.net
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests