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

Creating Hyper-V Replica Job

This example shows how to set up and manage a job that will replicate an SQL server. The replicated VM will be created on another site. This is a simple scenario illustrating basic operations with replication job and replica VM.

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-VBRHvReplicaJob. 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> $sourceserver = Get-VBRServer -Type HvServer -Name "srv03.veeam.local"

PS C:\PS> $targetserver = Get-VBRServer -Type HvServer -Name "srv02.veeam.remote"

PS C:\PS> Find-VBRHvEntity -Server $sourceserver -Name sql02 | Add-VBRHvReplicaJob -Name "SQL02 Replica job" -Server $targetserver -Path "c:\Replicas" -Description "SQL02 replication"

 

// Set the job schedule and enable it:

PS C:\PS> Get-VBRJob -Name "SQL02 Replica job" | Set-VBRJobSchedule -Periodicaly -FullPeriod 6 -PeriodicallyKind Hours | Enable-VBRJobSchedule

 

// Set email notification for the job:

PS C:\PS> Get-VBRJob -Name "SQL02 Replica job" | Set-VBRJobAdvancedNotificationOptions -EmailNotification-EmailNotificationAddresses "administrator@veeam.com"

 

// Look for the created replica VM:

PS C:\PS> Get-VBRReplica -Name "SQL02 Replica job"

 

// Look for the created replication job:

PS C:\PS> Get-VBRJob -Name "SQL02 Replica job"

 

// Suspend and resume the replication job:

PS C:\PS> Get-VBRJob -Name "SQL02 Replica job" | Disable-VBRJob

PS C:\PS> Get-VBRJob -Name "SQL02 Replica job" | Enable-VBRJob

 

// Remove the replication job:

PS C:\PS> Get-VBRJob -Name "SQL02 Replica job" | Remove-VBRJob

 

// Remove the replicated VM from disk:

PS C:\PS> Get-VBRReplica -Name "SQL02 Replica 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 Agent for Windows Documentation

Veeam Agent for Linux Documentation

Veeam Management Pack Documentation