Tag Archives: Backup

PowerShell Script to Export the newest VSS Consistent Snapshot from the Hyper-V Replica server

PowerShell Script to Export the last VSS Consistent Snapshot from the Hyper-V Replica server

Scenario:
Hyper-V Server 2012 R2 Cluster CLUSTERNAME with a Primary Server of the VM “VMNAME”
Hyper-V Server 2012 R2 Replica Server with a Replica of the VM “VMNAME”
Hyper-V Replica with VSS Consistent Snapshots History

How can i Export the newest VSS Consistent Snapshot from the Hyper-V Replica Server in order to avoid Backup/Export IO on the Primary Servers Storage?

$VM = "VMNAME"
$ReplicaHOST = Get-Cluster CLUSTERNAME | Get-ClusterResource ("Virtual Machine Configuration " + $VM) | Get-VM | Get-VMReplication | Select-Object -ExpandProperty ReplicaServer
Get-VMSnapshot -ComputerName $ReplicaHOST -VMName $VM -SnapshotType AppConsistentReplica | Sort-Object CreationTime -descending | Select-Object -first 1 | Start-VMFailover -AsTest -Confirm:$false
Get-VM -ComputerName $ReplicaHOST ($VM + " - Test") | Export-VM -Path "d:\

Add a line to clean up the Test Failover VM
You have a VSS Consistent/Ready to Import VM
Unfortunately there is a differential disk AVHD(X) File you have to merge

Advertisements