PowerShell script exchange
Post Reply
amiasoedov
Novice
Posts: 3
Liked: 1 time
Joined: Dec 30, 2015 7:27 am
Full Name: Alexey Miasoedov
Contact:

Add vCloud vApp/VM to the existing backup job

Post by amiasoedov »

Which cmdlets should I use to add vCloud vApp/VM to the existing backup job? I struggled to do this with Add-VBRJobObject / Add-VBRViJobObject.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by veremin »

What particular issue you came across while trying to add vCD entity to a job via Add-VBRViJobObject? Also, is it a vCD backup job?
amiasoedov
Novice
Posts: 3
Liked: 1 time
Joined: Dec 30, 2015 7:27 am
Full Name: Alexey Miasoedov
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by amiasoedov »

You cannot pass an item of type CVcdVmItem (returned by Find-VBRvCloudEntity) to Add-VBRViJobObject cmdlet (requires IViItem).

Code: Select all

public class CVcdVmItem : IVcdItem, IVmItem, IItem, IEquatable<CVcdVmItem>
public interface IViItem : IItem
Here is an example:

Code: Select all

$cloud_vm = Find-VBRvCloudEntity -Name 'CARROLLWEB01' -Server $vCloud | ? Type -eq Vm
$test_job = Get-VBRJob -Name TestBackupJob
$test_job.BackupPlatform
EVcd

Add-VBRViJobObject -Job $test_job -Entities $cloud_vm
Add-VBRViJobObject : Cannot bind parameter 'Entities'. Cannot convert the "Veeam.Backup.Core.Infrastructure.CVcdVmItem" value of type 
"Veeam.Backup.Core.Infrastructure.CVcdVmItem" to type "Veeam.Backup.Core.Infrastructure.IViItem".
tsightler
VP, Product Management
Posts: 6009
Liked: 2842 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by tsightler » 2 people like this post

I don't think there's a Powershell cmdlet to do this, although perhaps someone will correct me. However, I've successfully used this workaround:

Code: Select all

$cloud_vm = Find-VBRvCloudEntity -Name 'CARROLLWEB01' -Server $vCloud | ? Type -eq Vm
$test_job = Get-VBRJob -Name TestBackupJob
$added = $failed = $null
[Veeam.Backup.Core.Infrastructure.CJobItemsHelper]::TryAddItemsToJob($test_job, $cloud_vm, [ref] $added, [ref] $failed)
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by veremin »

I was about to write the same. Current vCD commandlets allow to add objects only during job creation. In order to add objects to existing job you have to load assembly and work with the mentioned methods. Thanks.
amiasoedov
Novice
Posts: 3
Liked: 1 time
Joined: Dec 30, 2015 7:27 am
Full Name: Alexey Miasoedov
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by amiasoedov » 1 person likes this post

Thank you guys! This works perfectly.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by veremin » 1 person likes this post

You're welcome. By the way, thank you for raising that again, we'll see what can be done in this regard in future.
Reittier
Lurker
Posts: 2
Liked: never
Joined: Sep 01, 2017 1:15 pm
Full Name: Sebastian Reitter
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by Reittier »

v.Eremin wrote:You're welcome. By the way, thank you for raising that again, we'll see what can be done in this regard in future.
is this done yet?
Reittier
Lurker
Posts: 2
Liked: never
Joined: Sep 01, 2017 1:15 pm
Full Name: Sebastian Reitter
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by Reittier »

Thanks, this helped me!
Did yozu address this in the mean time?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by veremin » 1 person likes this post

Nope, however, the provided workaround that includes loading assembly should be still a way to go. Thanks.
twkonefal
Lurker
Posts: 1
Liked: never
Joined: Dec 08, 2017 1:48 pm
Full Name: T. Konefal
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by twkonefal »

In order to back up a vApp I have code like this, but it is PAINFULLY slow (nearly a minute per query). I'm unable to change the vcdsystem type to anything else and still get a result for the find-vbrvcloudentity call. Using find-vbrvientity doesn't work for vApps.

Code: Select all

$s = get-vbrserver -type vcdsystem
$vcloudvApp = find-vbrvcloudentity -name 'Entity' -server $s -vApp
...
Is there a faster way to get this object so I can feed it to the TryAddItemsToJob call?

Code: Select all

[Veeam.Backup.Core.Infrastructure.CJobItemsHelper]::TryAddItemsToJob($test_job, $cloud_vm, [ref] $added, [ref] $failed)
phenton
Lurker
Posts: 2
Liked: never
Joined: Oct 14, 2016 2:31 pm
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by phenton »

Did anybody find a better/faster solution for adding vApps to an existing job?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by veremin »

As far as I'm concerned, currently that is the only workaround available. Thanks.
dlapointe
Service Provider
Posts: 25
Liked: 2 times
Joined: Jan 08, 2019 2:47 pm
Full Name: Dominic Lapointe
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by dlapointe »

Did anybody find a way to add vCloud VDC instead of just vApps to an existing job?
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Add vCloud vApp/VM to the existing backup job

Post by oleg.feoktistov »

Hi Dominic,

Try the code below:

Code: Select all

$entity = Find-VBRvCloudEntity -Name 'organization-vdc-1' -OrganizationVdc
$job = Get-VBRJob -Name 'VCLOUD-BACKUP'
Add-VBRvCloudJobObject -Job $job -Entities $entity 
Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests