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:
- Create a replication job with Add-VBRHvReplicaJob. 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> $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 "firstname.lastname@example.org"
// 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