Help Center
Choose product document...
Veeam Backup & Replication 9.5
PowerShell Reference

Creating VMware Replica Job

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:

  1. Create a replication job with Add-VBRViReplicaJob. With one job, you can replicate more than one VM.

If you need the replicated VMs, get them with Get-VBRReplica. To get the replication job, run Get-VBRJob.

  1. Configure a schedule with Set-VBRJobSchedule and apply it to the job. Remember to enable the schedule with Enable-VBRJobSchedule.
  2. 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.
  3. 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.
  4. 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.
  5. 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 "administrator@veeam.com"

 

// Add network mapping to the replica settings:

PS C:\PS> $sourcenetwork = Get-VBRServer -Name "192.12.11.199" | 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

Veeam Large Logo

User Guide for VMware vSphere

User Guide for Microsoft Hyper-V

Enterprise Manager User Guide

Veeam Cloud Connect Guide

Veeam Backup Explorers User Guide

PowerShell Reference

RESTful API Reference

Veeam Backup FREE Edition User Guide

Veeam Backup for Microsoft Office 365

Veeam ONE Documentation

Veeam Endpoint Backup Documentation

Veeam Management Pack Documentation