This example shows how to set up and manage a job that will replicate a domain controller server. The replicated VM will be created on another site. After the replication job is configured, a network mapping will be added.
Before replicating a VM to another host, make sure that the source host and target host are added to Veeam Backup & Replication.
To replicate a VM, you need to perform the following operations:
- Create a replication job with Add-VBRViReplicaJob. With one job, you can replicate more than one VM.
- Configure a schedule with Set-VBRJobSchedule and apply it to the job. Remember to enable the schedule with Enable-VBRJobSchedule.
- You can set email notification that will send information on result after each job run. Remember that email notifications for jobs will work only if you enable the global email notifications.
- If you need to suspend the replication job for a while, run Disable-VBRJob. To resume the replication, run Enable-VBRJob. The replication job will bring the VM state into sync with the first run.
- If you want to stop replicating the VM, you need to delete the replication job with Remove-VBRJob. Note that running Stop-VBRJob will stop the job once: it will start again on the next scheduled run.
- When you remove the replication job, the replica VM remains on disk, it only stops being synchronized with the original VM. If you do not need the replicas, you can remove them from Veeam Backup console by running Remove-VBRReplica or remove them completely by running Remove-VBRReplica with -FromDisk parameter.
// Create a replica job:
PS C:\PS> $server = Get-VBRServer -Type ESXi -Name "172.16.14.19"
PS C:\PS> $resourcepool = Find-VBRViResourcePool -Server $server -Name "Replicas"
PS C:\PS> $datastore = Find-VBRViDatastore -Server $server -Name "LocalStore01"
PS C:\PS> $folder = Find-VBRViFolder -Server $server -Name "VM"
PS C:\PS> Find-VBRViEntity -Name "DC" | Add-VBRViReplicaJob -Name "DC Replication Job" -Server $server -Datastore $datastore -ResourcePool $resourcepool -Folder $folder -Suffix "_replica" -Description "DC server replication"
// Set the job schedule and enable it:
PS C:\PS> Get-VBRJob -Name "DC Replication Job" | Set-VBRJobSchedule -Daily -At "23:00" -DailyKind SelectedDays -Days Saturday | Enable-VBRJobSchedule
// Set email notification for the job:
PS C:\PS> Get-VBRJob -Name "DC Replication Job" | Set-VBRJobAdvancedNotificationOptions -EmailNotification-EmailNotificationAddresses "firstname.lastname@example.org"
// Add network mapping to the replica settings:
PS C:\PS> $sourcenetwork = Get-VBRServer -Name "184.108.40.206" | Get-VBRViServerNetworkInfo
PS C:\PS> $targetnetwork = Get-VBRViServerNetworkInfo -Server $server
PS C:\PS> $dcreplica = Get-VBRJob -Name "DC Replication Job"
PS C:\PS> Set-VBRViReplicaJob -Job $dcreplica -EnableNetworkMapping -SourceNetwork $sourcenetwork -TargetNetwork $targetnetwork
// Look for the created replica VM:
PS C:\PS> Get-VBRReplica -Name "DC Replication Job"
// Suspend and resume the replication job:
PS C:\PS> Get-VBRJob -Name "DC Replication Job" | Disable-VBRJob
PS C:\PS> Get-VBRJob -Name "DC Replication Job" | Enable-VBRJob
// Remove the replication job:
PS C:\PS> Get-VBRJob -Name "DC Replication Job" | Remove-VBRJob
// Remove the replicated VM from disk:
PS C:\PS> Get-VBRReplica -Name "DC Replication Job" | Remove-VBRReplica -FromDisk