PowerShell script exchange
Post Reply
misteritgeek
Service Provider
Posts: 9
Liked: 2 times
Joined: Mar 17, 2017 8:32 pm
Contact:

Set target WAN Accelerator for a CloudConnect Copy Job

Post by misteritgeek »

Hello,
I am scripting the creation of a backup copy job to a target CloudConnect repository. The tenant I'm using has a Service Provider WAN Accelerator resource assigned to it.

The issue I'm hung up on is that I can't figure out how to populate the target accelerator (the one at the CloudConnect SP). Get-VBRWANAccelerator only returns the single local accelerator on the B&R server, as expected since the target WAN accelerator is normally greyed out and auto-populates in the GUI.

The problem is that the Add-VBRComputerBackupCopyJob cmdlet requires -something- as a -TargetAccelerator.

Code: Select all

$SourceWANAccelerator = Get-VBRWANAccelerator
Add-VBRComputerBackupCopyJob -SourceAccelerator <CWanAccelerator> -TargetAccelerator <CWanAccelerator> [-Name <string>]...
I tried approaching the issue from a different angle by setting up the Cloud Copy job without WAN acceleration and then adding it to the job options retroactively.

Code: Select all

$JobOptions = New-VBRJobOptions -ForBackupJob
$JobOptions.JobOptions.UseWan = 'True'

$CopyJob = Get-VBRJob -Name $CopyJobName
Set-VBRJobOptions -Job $CopyJob -Options $JobOptions
The JobOptions.UseWan property enabled WAN Acceleration... but this leaves the source WAN Accelerator undefined. I used Get-VBRJob (flattened with ConvertTo-Json) to pull the config of a test CloudConnect Copy job that had WAN Acceleration enabled using the GUI. I hoped to find the source WAN accelerator ID somewhere, but it actually does not seem to exist. :o

I found one of @Mildur 's suggestions from another thread and only the .FindSourceWanAccelerator() method returns a PS object for a CloudConnect copy job set up with WAN accel from the GUI.

Code: Select all

PS C:\Users\Administrator> $CopyJob = Get-VBRJob -Name $CopyJobName
PS C:\Users\Administrator> $CopyJob.FindTargetWanAccelerator()
PS C:\Users\Administrator> $CopyJob.FindSourceWanAccelerator()

Id          : b7050fe9-7a98-4dbd-b7db-61729c2aca30
Name        : LAB-WIN-SVR2016
Description : WAN Accelerator 01
HostId      : 6745a759-2205-4cd2-b172-8ec8f7e60ef8
Options     : Veeam.Backup.Core.CDomWaOptions
Thanks for any help you can offer!

misteritgeek
Service Provider
Posts: 9
Liked: 2 times
Joined: Mar 17, 2017 8:32 pm
Contact:

Re: Set target WAN Accelerator for a CloudConnect Copy Job

Post by misteritgeek »

I ended up opening support case #04680936 about this one. It really seems like Get-VBRWANAccelerator should have been the one-stop-shop for the Service Provider's WAN accel info I needed.

I did notice something interesting in the Veeam Powershell Library though. The "AddVBRHvCloudReplicaJob.cs" class contained a method I looked into further.

Code: Select all

IWanAcceleratorItem iwanAcceleratorItem1 = this.SourceWANAccelerator == null ? (IWanAcceleratorItem) null : this.SourceWANAccelerator.CreateItem();

IWanAcceleratorItem iwanAcceleratorItem2 = ((IEnumerable<IWanAcceleratorItem>) WanAcceleratorsProvider.GetWanAcceleratorItems(CCloudConnectHost.DbGet(this.Server.Id))).FirstOrDefault<IWanAcceleratorItem>();

this.WriteObject((object) new CBackupJob(CServiceJobBuilder.CreateViJobBuilder((EDbJobType) 1, (CDbBackupJobInfo.ETargetType) 100, cdbJobCommonInfo, this.BackupRepository.get_Id(), this.Server.Id, CLegacyPath.get_Empty(), "replica", this.RepositorySeed == null ? Guid.Empty : this.RepositorySeed.get_Id(), this._items.ToArray(), new CExcludedItem[0], array, new CItemDiskFilter[0], new CItemGuestProcessingInfo[0], (IProxyServer[]) this.SourceProxy, (IProxyServer[]) new CViProxy[0], cjobOptions, CGuestProcessingOptions.CreateDefaultForReplicaJob(), new IProxyServer[0], ScheduleOptions.CreateDefault(), this._mappingController == null ? new Dictionary<IItem, IItem>() : this._mappingController.CreateVmMapping(), (CBackupAttachmentSpec) CBackupAttachmentSpec.Empty, 0L, new Guid?(), iwanAcceleratorItem1 != null ? iwanAcceleratorItem1.get_WanID() : Guid.Empty, iwanAcceleratorItem2 != null ? iwanAcceleratorItem2.get_WanID() : Guid.Empty, ((IEnumerable<CBackupRepository>) this.SourceRepository).Select<CBackupRepository, Guid>((Func<CBackupRepository, Guid>) (repo => repo.get_Id())).ToArray<Guid>(), Guid.Empty, Guid.Empty, 0).CreateJob()));
iwanAcceleratorItem2 seems to be there to auto-detect a CloudConnect WAN Accel. I tried calling the same .NET call, but alas it seems to be specific to Service Provider replica resources and only returns local WAN accelerators in my case.

Code: Select all

[Veeam.Backup.Core.WanAcceleratorsProvider]::GetWanAcceleratorItems()
Id          : b7050fe9-7a98-4dbd-b7db-61729c2aca30
Name        : LAB-WIN-SVR2016
Path        :
WanID       : b7050fe9-7a98-4dbd-b7db-61729c2aca30
Description : WAN Accelerator 01

oleg.feoktistov
Veeam Software
Posts: 915
Liked: 325 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Set target WAN Accelerator for a CloudConnect Copy Job

Post by oleg.feoktistov »

Hi @misteritgeek,

I'm very sorry for not responding to you here in time. It seems that this thread got lost among other numerous questions.
But I took some time to review your case and did some tests together with dev/qa. As per our findings, we have a validation snippet on our backend to check if target repository is a cloud one. If it is, Add-VBRComputerBackupCopyJob cmdlet does not require -TargetAccelerator parameter and uses the one from Service Provider's side by default. We could reproduce your issue only in scenario when target repository is not the one allocated by SP, but the one created on tenant's VBR side:

Code: Select all

 Add-VBRComputerBackupCopyJob : Specify TargetWanAccelerator parameter
At line:5 char:1
+ Add-VBRComputerBackupCopyJob -Name 'Test' -Description 'Test' -Backup ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-VBRComputerBackupCopyJob], Exception
    + FullyQualifiedErrorId : System.Exception,Veeam.Backup.PowerShell.Cmdlets.AddVBRComputerBackupCopyJob 
Could you, please, clarify which scenario you tried to create agent backup copy job on tenant's side?

We did noticed that Add-VBRViBackupCopyJob cmdlet doesn't have such validation, so we are going to address it internally.

Thanks,
Oleg

misteritgeek
Service Provider
Posts: 9
Liked: 2 times
Joined: Mar 17, 2017 8:32 pm
Contact:

Re: Set target WAN Accelerator for a CloudConnect Copy Job

Post by misteritgeek »

Thanks @oleg.feoktistov,
Sorry, I noticed an error in my original post. I never actually used the Add-VBRComputerBackupCopyJob cmdlet as implied by the example; instead I'm exclusively using the Add-VBRHvBackupCopyJob cmdlet in all tests (I do intend on using Add-VBRViBackupCopyJob the same way).

It sounds like you already validated the issue I encountered with Add-VBRHvBackupCopyJob, where the -TargetAccelerator parameter is required even when directed at a cloud repo using a Service Provider's WAN accelerator. A similar validation snippet to check if target repository is a cloud one would be perfect here. No pressure, but I hope it makes it to a release soon :)

I'm particularly curious how Veeam "uses the target WAN accelerator from Service Provider's side by default" as you mentioned, I sense a viable work-around for what I'm doing now nearby. I'm not sure about the implementation details, so I might be asking the wrong question here, but assuming that the tenant knows about the SP WAN accelerator: Do you know if there is a work-around I could use to discover the Service provider's WAN Accelerator to supply a valid -TargetAccelerator when using Add-VBRHvBackupCopyJob? Or if the SP WAN accelerator is never actually known within the tenant's job, would it be possible to invoke a method to modify an existing job to select the source WAN accelerator instead (leaving the target blank)?

oleg.feoktistov
Veeam Software
Posts: 915
Liked: 325 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Set target WAN Accelerator for a CloudConnect Copy Job

Post by oleg.feoktistov » 1 person likes this post

Hi,

I see now :D

Actually, we discovered that all Add-VBR*BackupCopyJob cmdlets except for the one for agents don't have such validation, so we submitted bugs for all of them. No ETA here, but plans are to include these fixes in the next release.

I'm afraid there isn't any workaround for this. The point is that target accelerator status you see in the job creation wizard is obtained from [Backup.Model.CloudRepositories] table and can be retrieved through powershell only with the following code:

Code: Select all

$provider = Get-VRBCloudProvider
$provider.Resources[0].WanAcceleratorEnabled
Now, to pass it to -TargetAccelerator parameter, you need to have object of CWanAccelerator class. Information to instantiate objects of this class is obtained from [WanAccelerators] table. And data on service provider's accelerators is never written there on tenant's side by design.
As for leaving target accelerator blank - even if there was a method for that, you would still need to have a validation snippet mentioned above to determine whether we need to use SP's accelerator as a target. Otherwise, leaving target accelerator blank would invoke numerous failures for sure.

Thanks,
Oleg

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests