PowerShell script exchange
Post Reply
Leo0601
Enthusiast
Posts: 88
Liked: 8 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

create SureBackup job in V12

Post by Leo0601 »

Hi Experts,

I am not able to create Veeam sure backup job in Veeam 12. I am getting the below error. Could someone help me to fix this issue.

Add-VBRApplicationGroup : A Parameter cannot be found that matches parameter name 'VBRSureBackupVM'
Add-VBRApplicationGroup : Cannot validate argument on parameter ''Name". Application name with specified group already exists.
Cannot process argument transformation on parameter "Job". Cannot find job by name

We are doing something wrong. Experts could someone help me to fix this issue. I am ready to share the code as well.

I am looking forward to hearing from you.

Regards
Leo
david.domask
Veeam Software
Posts: 2622
Liked: 611 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: create SureBackup job in V12

Post by david.domask » 1 person likes this post

Hi Leo,

Yes, if you could share your script and what you passed as parameters?

I'll link the User Guide page for Add-VBRApplicationGroup here as we will need to reference it.

I will go through your errors one by one here:

1. A Parameter cannot be found that matches parameter name 'VBRSureBackupVM'

Seems like you tried to add a Parameter -VBRSureBackupVM, but the parameter as per the User Guide is -VM. VBRSureBackupVM is the object type you need to pass to -VM, and you get a VBRSureBackupVM object with the cmdlet listed in the User Guide

2. Add-VBRApplicationGroup : Cannot validate argument on parameter ''Name". Application name with specified group already exists.

Exactly as the message tells -- Add-VBRApplicationGroup creates a new application group, but sounds like the name you are trying to use already is in use by another Application Group. Simply pick a different name.

3. Cannot process argument transformation on parameter "Job". Cannot find job by name

Not sure this is from Add-VBRApplicationGroup but instead Add-VBRSureBackup job.


For creating a SureBackup job with Powershell, please start with the example on this page and try to do it by hand first following the example.

If you still have difficulties, please share your script and the errors you try to run it.
David Domask | Product Management: Principal Analyst
Leo0601
Enthusiast
Posts: 88
Liked: 8 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: create SureBackup job in V12

Post by Leo0601 »

@david.domask

Hi David,

Thank you so much for your reply. Yes we are following the same link which was shared by you.

As you mentioned, Instead of -VBRSureBackupVM I have tried with -VM as well. We are getting an below error.
ApplicationGroup : Cannot bind parameter 'VM', Cannot convert the "Veeam.Backup.Core.Infrastructure.CViVmItem" value of type "Veeam.Backup.Core.Infrastructure.CViVmItem" to type "Veeam.Backup.Powershell.Infos.VBRSureBackupVM".
Sure, I will attach the script below.

We are using the existing script. We are not expert in it. If you help me to fix this issue, It means a lot.

I am looking forward to hearing from you.

Regards
Leo

Code: Select all

clear
write-host "`n`n`n==============================================================================="
write-host "============Veeam Application Group Creation & Sure BAck up ===================="
write-host "===============================================================================`n`n"
#Add-PSSnapin VeeamPSSnapin
Import-Module Veeam.Backup.PowerShell
$vlab = Get-VBRVirtualLab
$vname = ($($Vlab.name)).split(',')
$vlength = $vname.length
Write-host "number of virtual Lab found is '$vlength'"
#Write-host "your Virtual Lab is '$($Vlab.name)'"
for ($i=0;$i -le $vlength-1; $i++)
{

	write-host "	$($i+1). $($vname[$i])"
}
$in = Read-host "`n`nplease select virtual lab"

#write-host "v length is $vlength, and in is $in"
while($in -gt $vlength)
{
	$in = Read-host "please select correct virtual lab"
}

$in = $in - 1
$vlab = Get-VBRVirtualLab -name $vname[$in]

write-host "`n`nVirtual Lab selected is $($vlab.name) `n`n"

write-host " List of IMS Nodes available are below `n"
Write-host "	1.ISCV"
Write-host "	2.IECG"
Write-host "	3.XPER"
Write-host "	4.ISP"
Write-host "	5.DWP"
Write-host "	6.IBE"
Write-host "	7.PB"
Write-host "	8.Management nodes"
$input = Read-host "`n`nplease enter one Node from above to create application group and sure back up jobs"

while($input -gt 8)
{
	$input = Read-host "`n please select correct Node"
}


    
function create_group ($app)
{

    while($True)
	{
		$siteID1 = Read-Host -Prompt "`nEnter the Site ID name "
		$siteID2 = Read-Host -Prompt "`nRe-Enter the Site ID name "
			if ($siteID1 -ne $siteID2) 
			{
				Write-Host "Value does not match.. Enter SiteID"	-fore Red
			}
			else
			{
				Break
			}
	 }

	$IMSSiteID = $siteID1

    if($app -eq "Management")
    {
    $m = Find-VBRViEntity -name "*DN*","*DC1*","*BDC2*","*CU1*","*CU2*","*THYDE1*","vcenter" | where {$_.Type -Match "VM"}
    Add-VBRApplicationGroup -name "$app" -VM $m
    $n = Get-VBRApplicationGroup -name "$app"
    Add-VBRJob -Name "$app"-VirtualLab $vlab -AppGroup $n
    Get-VBRJob -Name "$app" | Set-VBRJobSchedule -Monthly
    }
    else
	{
    $a = Find-VBRViEntity -name "*$app*TST*" | where {$_.Type -Match "VM"}
    Add-VBRApplicationGroup -name "$($app)_Test" -VM $a
    $b = Find-VBRViEntity -name "*$app*" | where {$_.Name -Notmatch "TST"} | where {$_.Type -Match "VM"}
    Add-VBRApplicationGroup -name "$($app)_production" -vm $b
    $c = Get-VBRApplicationGroup -name "$($app)_production"
    $d = Get-VBRApplicationGroup -name "$($app)_Test"
    Add-VBRViJobObject -Job "$($IMSSiteID)_SureBackup_Production_$($app)"-VirtualLab $vlab -AppGroup $c
    Add-VBRViJobObject -Job "$($IMSSiteID)_SureBackup_Test_$($app)"-VirtualLab $vlab -AppGroup $d
    Get-VBRJob -Name "$($IMSSiteID)_SureBackup_Production_$($app)" | Set-VBRJobSchedule -daily
    Get-VBRJob -Name "$($IMSSiteID)_SureBackup_Test_$($app)" | Set-VBRJobSchedule -Monthly
	}
}

switch($input){
1 {
create_group("ISCV")
}
2 {
create_group("IECG")
}
3 {
create_group("XPER")
}
4 {
create_group("ISP")
}
5 {
create_group("DWP")
}
6 {
create_group("IBE")
}
7 {
create_group("PB")
}
8 {
create_group("Management")
}
}
Leo0601
Enthusiast
Posts: 88
Liked: 8 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: create SureBackup job in V12

Post by Leo0601 »

@david.domask

Hi David,

We have raised a case last week itself. This is the case id : 07455909. But no proper support from them.

If you help us to fix it. It means a lot.

Regards
Leo
david.domask
Veeam Software
Posts: 2622
Liked: 611 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: create SureBackup job in V12

Post by david.domask » 1 person likes this post

Hi Leo,

Thank you for sharing the case, however, script design assistance is indeed outside the scope of Support as per the Support Policy (5.8, User Scripts). I can see the Support Engineer went a bit beyond this and provided a few pointers on your script, which is great, but the forums are the correct place for general design questions like this.

As for your code:

Code: Select all

$m = Find-VBRViEntity -name "*DN*","*DC1*","*BDC2*","*CU1*","*CU2*","*THYDE1*","vcenter" | where {$_.Type -Match "VM"}
Add-VBRApplicationGroup -name "$app" -VM $m

This part is failing because Add-VBRApplicationGroup requires a different object passed to the -Vm parameter, you cannot use Find-VBRViEntity.

Use New-VBRSureBackupVM to add machines to an Application Group.

This cmdlet will need either a restore point returned by Get-VBRRestorePoint or a Job Object returned by Get-VBRJobObject. I will demonstrate with passing a RestorePoint here briefly.

Code: Select all

$backup = Get-VBRBackup -name "name of the backup with machines you want in the Application Group"
$rp = Get-VBRRestorePoint -Backup $backup | Sort-Object -Property CreationTime -Descending | Select -First 1 #get newest restore point for machine
$newSbVm = New-VBRSureBackupVM -RestorePoint $rp
$appGroup = Add-VBRApplicationGroup -Name "New App Group" -Vm $newSbVm
Once that is done, then you'll have your application group created and you can add it to a SureBackup job.

I note you have a line:

Add-VBRJob -Name "$app"-VirtualLab $vlab -AppGroup $n

The correct cmdlet for making a new SureBackup job is Add-VBRSureBackupJob, which you will need to add the parameters for.
David Domask | Product Management: Principal Analyst
Leo0601
Enthusiast
Posts: 88
Liked: 8 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: create SureBackup job in V12

Post by Leo0601 » 1 person likes this post

@david.domask

Hi David,

Thanks much for the explanation. Its really helpful for my code creation.

It solved the issue. I just wanted to give credit to you. Now I am able to create Veeam surebackup job application group and a surebackup job.

As you mentioned, the old logic with which we are trying to create a surebackup job and application group by adding VM's separately is not working in Veeam 12.

I have modified the code as per your logic.
* Provided the name for the SureBackup job application group
* Adding Veeam backup job (Instead of VM's) by sorting out the latest restore point while creating Surebackup job application group.
* Later adding that same Surebackup application group to Surebackup job for our test and production servers.
* While adding Surebackup application group to Surebackup, Adding virtual lab as well.

If you have any survey link share to email id. I will give positive feedback for you.

I am sharing the code that I have created. Maybe it will be useful for someone else as well.

Code: Select all

 $jobname = $IMSSiteID + "_Production_" + $app
    Write-host "Creating Job for Jobname:" + $jobname
    $backup = Get-VBRBackup -name $jobname
    $rp = Get-VBRRestorePoint -Backup $backup | Sort-Object -Property CreationTime -Descending | Select -First 1 
    $newSbVm = New-VBRSureBackupVM -RestorePoint $rp
    Write-host "Creating Application Group. Name: " +  $jobname
    $appGroup = Add-VBRApplicationGroup -Name $jobname -VM $newSbVm
    $surebackupjobname = $jobname + "_SUREJOB"
    Write-host "Creating Sure Backup Job. Name: " + $surebackupjobname
    $surebackupjob = Add-VBRSureBackupJob -ApplicationGroup $appGroup -VirtualLab $vlab -Name $surebackupjobname

    $jobname = $IMSSiteID + "_Test_" + $app
    Write-host "Creating Job for Jobname:" + $jobname
    $backup = Get-VBRBackup -name $jobname
    $rp = Get-VBRRestorePoint -Backup $backup | Sort-Object -Property CreationTime -Descending | Select -First 1 
    $newSbVm = New-VBRSureBackupVM -RestorePoint $rp
    Write-host "Creating Application Group. Name: " +  $jobname
    $appGroup = Add-VBRApplicationGroup -Name $jobname -VM $newSbVm
    $surebackupjobname = $jobname + "_SUREJOB"
    Write-host "Creating Sure Backup Job. Name: " + $surebackupjobname
    $surebackupjob = Add-VBRSureBackupJob -ApplicationGroup $appGroup -VirtualLab $vlab -Name $surebackupjobname
Regards
Leo
david.domask
Veeam Software
Posts: 2622
Liked: 611 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: create SureBackup job in V12

Post by david.domask » 1 person likes this post

Hi Leo,

Very glad I was able to help get you moving in the right direction, and thank you very much for sharing your script! I am certain it will help others.
David Domask | Product Management: Principal Analyst
Leo0601
Enthusiast
Posts: 88
Liked: 8 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: create SureBackup job in V12

Post by Leo0601 » 1 person likes this post

@david.domask

My pleasure, David.
Leo0601
Enthusiast
Posts: 88
Liked: 8 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: create SureBackup job in V12

Post by Leo0601 »

@david.domask

Hi David,

Sorry, I have one last question.

I am using your below piece of code to get latest restore point for a Backup. I have an issue with this now. For instance, $backup has multiple VMs and I need get latest restore point for all the VMs in a array. But the below code returns only one VM from the list that has the latest restore point. Can you help the with code to get restore points of each VMs in a array?

Code: Select all

    $rp = Get - VBRRestorePoint - Backup $backup | Sort - Object - Property CreationTime - Descending | Select - First 1 #get newest restore point
Thank you
Leo
david.domask
Veeam Software
Posts: 2622
Liked: 611 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: create SureBackup job in V12

Post by david.domask »

Hi Leo,

No worries, simply remove the final pipe to `Select -First 1`

that will return all restore points instead of just the most recent.
David Domask | Product Management: Principal Analyst
Leo0601
Enthusiast
Posts: 88
Liked: 8 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: create SureBackup job in V12

Post by Leo0601 » 1 person likes this post

@david.domask

Once again thanks much David.

You helped me to fix it out. :) :)
Post Reply

Who is online

Users browsing this forum: kocit and 17 guests