Add VM to Existing Backup Job VMs and Templates View

PowerShell script exchange

Add VM to Existing Backup Job VMs and Templates View

Veeam Logoby jevao » Fri Jun 20, 2014 4:39 am

Hello, Trying to add a VM to a Backup Job, but would like the VMs Path to use the VMs and Templates view, instead of the Hosts and Clusters View.
Have not found the code to add or change a VMs Path in an already existing backup job to a VMs and Templates folder.

Using the Add-VBRviBackupJob I am able to add a VM using the VMs and Templates folder using the -Entity option.

Code: Select all
$allvms = Find-VBRViEntity -VMsAndTemplates
$CreateJobVM = $allvms | ? { $_.name -in $VM }
Add-VBRViBackupJob -Name $CreateJobName -BackupRepository $CreateJobRep -Entity $CreateJobVM


But once the Backup Job is Created,
the only cmdlet I have found to add another VM to this already created Backup Job is "Add-VBRJobObject".

I have not figured out how to add a VM using the "Add-VBRJobObject" cmdlet that uses the VMs and Templates view.

Is it possible?
Thanks
jevao
Enthusiast
 
Posts: 29
Liked: 3 times
Joined: Fri Oct 28, 2011 11:38 pm
Full Name: James Collison

Re: Add VM to Existing Backup Job VMs and Templates View

Veeam Logoby v.Eremin » Fri Jun 20, 2014 9:01 am 1 person likes this post

You can use Add-VBRViJobObject commandlet in order to add object to existing job. The script should look like the following:

Code: Select all
$Job = Get-VBRJob -name "Name of your backup job"
$Entity = Find-VBRViEntity -VMsAndTemplates -name "Name of your VM or template"
Add-VBRViJobObject -Job $Job -Entities $Entity


Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Add VM to Existing Backup Job VMs and Templates View

Veeam Logoby jevao » Fri Jun 20, 2014 4:34 pm

That was exactly what I needed. Thanks.
jevao
Enthusiast
 
Posts: 29
Liked: 3 times
Joined: Fri Oct 28, 2011 11:38 pm
Full Name: James Collison

Re: Add VM to Existing Backup Job VMs and Templates View

Veeam Logoby v.Eremin » Mon Jun 23, 2014 8:47 am

You're welcome. Feel free to contact us, if any other help is needed. Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Add VM to Existing Backup Job VMs and Templates View

Veeam Logoby deibel » Thu Mar 31, 2016 11:36 am

Hi,
what do i need to add if i wannt to add a VM to all my Backup Jobs?

regards
deibel
Lurker
 
Posts: 1
Liked: never
Joined: Thu Mar 31, 2016 10:43 am

[MERGED]:Find-VBRHvEntity takes forever - is there a faster

Veeam Logoby jansjone » Thu Jun 09, 2016 2:19 pm

Whenever I add a VM to a backup job using Powershell, it takes many minutes to do so, because Find-VBRHvEntity takes so long. Is there any way to add a VM to a job via Powershell without using this cmdlet, or is there a way to somehow speed it up? Also, I often delete and recreate VMs using the same name, and when I do, Veeam backups will fail unless I drop and re-add the VM to my backup job. I have Powershell to drop and re-add the VM, but it requires using Find-VBRHvEntity, which takes over 4 minutes to return a single object.

Here's my simplified code:
Code: Select all
  $Cluster = 'MyTestCluster"
  $VM = 'MyTestVM'
  $VBRJob = Get-VBRJob -Name MyTestJob

  #### This line takes over 4 minutes to run, but I don't see another way to  get a $VBRVMEntity object than using Find-VBRHVEntity ####
  $VBRVMEntity = Get-VBRServer -name $Cluster | Find-VBRHvEntity -Name $VM
  Add-VBRHvJobObject -Job $VBRJob -Entities $VBRVMEntity


Thanks,
Janssen
jansjone
Lurker
 
Posts: 1
Liked: never
Joined: Thu Jun 09, 2016 2:03 pm
Full Name: Janssen Jones

Re: Add VM to Existing Backup Job VMs and Templates View

Veeam Logoby v.Eremin » Mon Jun 20, 2016 6:04 pm

Does you original, not simplified code has a cycle by any chance? If so, you can create a hash table (as described here) to run the said query only once - this should speed up the process significantly. Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: robbysmith and 4 guests