PowerShell script exchange
Post Reply
zjerinasite
Novice
Posts: 6
Liked: never
Joined: Aug 15, 2022 6:59 am
Full Name: Ziga
Contact:

Replication Job Disk Target Datastore Selection (Powershell)

Post by zjerinasite »

We are using Powershell to automate our replication job creation and settings, but I cannot seem to find the option "Pick datastore" in the Powershell job options.

What I would like to do is select a different datastore for each disk using Powershell.
This is the same option that can be found in the VBR Console when right clicking on a replication job and selecting "Edit" -> "Destination" -> "Pick datastore" -> Select hard disk -> "Datastore" -> Select datastore.

We are using VBR version 12.
david.domask
Veeam Software
Posts: 2573
Liked: 603 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Replication Job Disk Target Datastore Selection (Powershell)

Post by david.domask » 1 person likes this post

Hi Ziga,

Right now not possible with Powershell, but as a workaround I _think_ these old unsupported methods still work:

post318754.html#p318754
powershell-f26/example-replica-vm-disk- ... 23725.html

I think the cmdlet should handle this just fine (both Set- and Add- VBRViReplicaJob, but I would test it first with a "dummy" VM before setting up your jobs this way.
David Domask | Product Management: Principal Analyst
zjerinasite
Novice
Posts: 6
Liked: never
Joined: Aug 15, 2022 6:59 am
Full Name: Ziga
Contact:

Re: Replication Job Disk Target Datastore Selection (Powershell)

Post by zjerinasite »

Thank you David for your response,

I have managed to finally implement the per-disk datastore selection using Powershell and it seems to work, but it would be great if someone would approve if this is the correct approach, what I did was:

Code: Select all

$jobObject = Get-VBRJobObject -Job $job
$jobObject.ExtendedOptions.TargetOptions.DiskDestination[1].TargetDatastoreName = 'DS2'
$jobObject.ExtendedOptions.TargetOptions.DiskDestination[1].TargetDatastoreRef = 'group-p2'
$jobObject.Update($jobObject.Location, $jobObject.OrderNo, $jobObject.ExtendedOptions)
david.domask
Veeam Software
Posts: 2573
Liked: 603 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Replication Job Disk Target Datastore Selection (Powershell)

Post by david.domask » 1 person likes this post

Hi Ziga,

It looks correct based on the previous threads; however, as this is getting into unsupported methods/territory, I would advise do testing first as this is circumventing the intended behavior of the cmdlets, so personally I would do a few failover tests and failbacks with a "dummy" vm you can play with. (perhaps just restore a backed up machine with a new name to an isolated network or no network and use that for testing)
David Domask | Product Management: Principal Analyst
zjerinasite
Novice
Posts: 6
Liked: never
Joined: Aug 15, 2022 6:59 am
Full Name: Ziga
Contact:

Re: Replication Job Disk Target Datastore Selection (Powershell)

Post by zjerinasite »

Lets say a disk is added to a virtual machine on vCenter.
Is there a way to sync the new disk data from vCenter for a job object?
david.domask
Veeam Software
Posts: 2573
Liked: 603 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Replication Job Disk Target Datastore Selection (Powershell)

Post by david.domask »

Hi Ziga,

Can you elaborate a bit more on your goal? Replica jobs work with VMs as objects so when the job does a lookup on the VM, it will find the new disk and it will be included in the replica.
David Domask | Product Management: Principal Analyst
zjerinasite
Novice
Posts: 6
Liked: never
Joined: Aug 15, 2022 6:59 am
Full Name: Ziga
Contact:

Re: Replication Job Disk Target Datastore Selection (Powershell)

Post by zjerinasite »

Hi David,

Lets say we have a VM called VM1 which has a single disk.
We fetch the VM1 job object using the following command:

Code: Select all

$jobObject = Get-VBRJobObject -Job $job
In the disk destinations a single disk will be shown with a target datastore:

Code: Select all

$jobObject.ExtendedOptions.TargetOptions.DiskDestination

DiskDatastoreSpec   : Veeam.Backup.Model.CViDiskDatastoreSpec
Key                 : SCSI 0:0 (Raw: 2000)
TargetDatastoreRef  : group-p1
TargetDatastoreName : DS
HDTargetType        : StoragePod
DiskCreationMode    :
If another disk is added to VM1 on the vCenter and the job object is re-fetched the disk destinations for the job object will not be updated (in the UI the disks are updated).
My question is if there is a way to trigger disk destinations update for the job object?
david.domask
Veeam Software
Posts: 2573
Liked: 603 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Replication Job Disk Target Datastore Selection (Powershell)

Post by david.domask »

Got it, I think you just need to refresh the $job variable first -- can you test if running Get-VBRJob first and then passing that fresh object to Get-VBRJobObject and see if it updates? Keep in mind, we're working with an unsupported method here so might not be able to pursue this too deeply, but my guess is one of two things is true:

1. It will work as expected if you retrieve the job with Get-VBRJob fresh
2. It will only show correctly after the next run of the Replica job
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests