You can invoke a planned failover on a target replication group and recover the devices on the target site. After that, you can reverse the direction of the replication and make the target site the source site.

Verify that you are connected to the vCenter Server systems of the source and target sites.

Verify that you have access to at least one virtual machine host on each site.

Verify that you have registered a Virtual Volume VASA provider and have access to a Virtual Volume datastore on each site.

1

Create a storage policy with replication capability on the source site.

$replicationCapability = Get-SpbmCapability -Name *replication.RPO -Server $srcServer
$persistenceCapability = Get-SpbmCapability -Name *persistence1-readLatency -Server $srcServer
$replicationRule = New-SpbmRule -Capability $ replicationCapability -Value (New-TimeSpan -Hours 4)
$persistenceRule = New-SpbmRule $persistenceCapability -Value 25
$ruleSet = New-SpbmRuleSet -AllOfRules $replicationRule, $persistenceRule
$replicationPolicy = New-SpbmStoragePolicy -Name cokeRep -AnyOfRuleSets $ruleSet -Server $srcServer
2

Get a datastore compatible with the created replication storage policy and store it in the $ds variable.

$ds = Get-SpbmCompatibleStorage -StoragePolicy $replicationPolicy
3

Create a virtual machine named MyVM with a hard disk in the $ds datastore.

$vm = New-VM -Name 'MyVM' -VMHost 'Host-Source' -DiskMB 512 -Datastore $ds
$hd = Get-HardDisk -VM $vm
4

Get a replication group for the $ds datastore and the $replicationPolicy storage policy, and store the replication group in the $rg variable.

$rg = Get-SpbmReplicationGroupDatastore $ds –StoragePolicy $replicationPolicy
5

Associate the $vm virtual machine and its hard disk with the $replicationPolicy storage policy, and put them in the $rg replication group.

Set-SpbmEntityConfiguration -Configuration $vm, $hd -StoragePolicy $replicationPolicy -ReplicationGroup $rg
6

Check the compliance of the $vm virtual machine and $hd hard disk with the $replicationPolicy storage policy.

Get-SpbmEntityConfiguration $vm, $hd
7

Get the replication pair corresponding to the $rg source replication group, and store that pair in the $rgPair variable.

$rgPair = Get-SpbmReplicationPair -Source $rg
8

Synchronize the target replication group.

Sync-SpbmReplicationGroup $rgPair.Target
9

Prepare the source Virtual Volume map of source devices of the datastore to be used in the failover cmdlet.

$dsUrl = $ds.ExtensionData.Info.Url
$dsUrl = $dsUrl.Remove($dsUrl.Length - 1)
$lastIndex = $dsUrl.LastIndexOf('/')
$containerId = $dsUrl.Substring($lastIndex + 1)
$vmVvolId = $vm.ExtensionData.Config.VmStorageObjectId
$hdVvolId = $hd.ExtensionData.Backing.BackingObjectId
$sourceVvolMap = @{$vmVvolId = $containerId; $hdVvolId = $containerId}
10

Power off the $vm virtual machine and unregister it.

Stop-VM $vm
Remove-VM $vm
11

Prepare the failover on the source replication group.

Start-SpbmReplicationPrepareFailover $rgPair.Source
12

Synchronize the target replication group again, to get the latest state of the source devices.

Sync-SpbmReplicationGroup $rgPair.Target
13

Invoke the planned failover on the source replication group and store the virtual machine file path on the target site in the $vmFilePath variable.

$vmFilePath = Start-SpbmReplicationFailover $rgPair.Target -SourceVvolMap $ sourceVvolMap
14

Register the virtual machine on the Host-Target host and power on the virtual machine.

$vm = New-VM -VMFilePath $vmFilePath -VMHost 'Host-Target'
Start-VM $vm
15

Reverse the direction of the replication.

Start-SpbmReplicationReverse $rgPair.Target