Skip to Content

Solved: How do I backup and replicate Hyper-V virtual machines?

You are more likely using VMware or Hyper-V if running virtual machines in the organization. Due to increasing number of Hyper-V users, you will need suitable and effective method to backup Hyper-V virtual machines as preventive measure for data protection against data threats.

Backup and replicate Hyper-V virtual machines allow you to roll back in time to restore the system to a particular point before the threat compromised the data.

Content Summary

Copy and paste manually
Create checkpoints
Export and import the virtual machine
Microsoft’s backup for VM
Third-party VM backup tool

Copy and paste manually

In order to have a copy of virtual machine’s files including hardware configuration, operating system, saved-state files, virtual hard disks, and network configuration files to another site, there are two methods to do this: Hot backup and Cold backup.

Cold backup

Cold Backup involves stopping the virtual machine and copying the files. Although we can write a script to perform necessary actions automatically, but we will suffer a short period of downtime. VM Cold backup method may not be suitable especially for those critical machines that need continuous uptime.

Hot backup (Volume Shadow Copy Service)

You can perform hot backup method using Microsoft Volume Shadow Copy Service (VSS) in order to avoid interrupting operations. The Volume Shadow Copy Service offers two options to backup VM as below:

  • Saved State: Put the virtual machine into a Saved State before the snapshot processing happens.
  • Child VM Snapshot: Backup Integration Service should be installed in the child VM. The VSS Requestor and VSS Writer coordinate to get a stable image of the VM.

Create checkpoints

Hyper-V Checkpoint create a point-in-time snap of virtual machine which able to roll back to the previous state quickly and easily if needed.

Perform below steps to change the checkpoint configuration for a Hyper-V virtual machine:

Step 1: Navigate to the Hyper-V virtual machine in Hyper-V Manager.

Step 2: Right-click on the virtual machine and select Settings option from the context menu.

Step 3: Expand the Management > Checkpoints option at the sidebar.

Step 4: Under the Checkpoint Type section, check the Enable checkpoints option.

Step 5: Select either Production checkpoints (selected by default) or Standard checkpoints.

Steps to change the checkpoint configuration for a Hyper-V virtual machine.

Step 6: Click on the Apply button.

Step 7: Click on the OK button to close the Settings box.

Warning: Checkpoints are stored on the Hyper-V host storage. If you lose storage that contains the Hyper-V virtual machine hard disk files, then the checkpoints will be lost altogether. Hence, never treat Checkpoints as Backups.

Export and import the virtual machine

Exporting a virtual image involves creating a copy of VM configuration files, VHD files, and VM snapshots in another location. The export of virtual machine can be done either when the VM is in running state or stopped state. The exported copy of Hyper-V virtual machine files can be imported into the same Hyper-V host or a new host and the virtual machine can be created.

Export Hyper-V VM using Hyper-V Manager

Step 1: Open the Hyper-V Manager.

Step 2: Right-click on the VM from the list.

Step 3: Select the Export option from the context menu to open the Export Virtual Machine wizard.

Open the Hyper-V Manager. Right-click on the VM from the list. Select the Export option from the context menu to open the Export Virtual Machine wizard.

Step 4: Click on the Browse button to specify the location where the VM should be exported.

Click on the Browse button to specify the location where the VM should be exported.

Step 5: The Status column show the progress of the Hyper-V Export operation.

The Status column show the progress of the Hyper-V Export operation.

Step 6: After the export process is completed, you can open the folder to verify that VM is successfully exported. The export location contains the Virtual Hard Disks, VM configuration files, and VM snapshots.

After the export process is completed, you can open the folder to verify that VM is successfully exported. The export location contains the Virtual Hard Disks, VM configuration files, and VM snapshots.

Export Hyper-V VM using PowerShell

Step 1: Press the Windows + R key to open the Run dialogue box.

Step 2: Type powershell then press the Ctrl + Shift + Enter key combination to open up an elevated PowerShell window. If the UAC (User Account Control) prompt, click Yes to grant administrator access.

Step 3: Type the following command to export Hyper-V VM using PowerShell:

Export-VM -Name “VMNAME” -Path “LOCATION”

Type the following command to export Hyper-V VM using PowerShell:  Export-VM -Name “VMNAME” -Path “LOCATION”

Step 4: Once the export process has finished checking the target location to verify that VM, the corresponding files will be successfully exported.

Once the export process has finished checking the target location to verify that VM, the corresponding files will be successfully exported.

Step 5: Type the following command to export all available Hyper-V VMs using PowerShell:

Get-VM | Export-VM -Path “LOCATION”

Type the following command to export all available Hyper-V VMs using PowerShell:  Get-VM | Export-VM -Path “LOCATION”

Import Hyper-V VM using Hyper-V Manager

Step 1: Open the Hyper-V Manager.

Step 2: Select the Import Virtual Machine option from the Actions section located at the right sidebar.

Select the Import Virtual Machine option from the Actions section located at the right sidebar.

Step 3: Click on the Next button for the Before You Begin section.

Click on the Next button for the Before You Begin section.

Step 4: Click on the Browse button in the Locate Folder section to select the VM folder which you want to import. In this case, we are importing the VM exported from another Hyper-V server and accessing files from the shared path.

Click on the Browse button in the Locate Folder section to select the VM folder which you want to import. In this case, we are importing the VM exported from another Hyper-V server and accessing files from the shared path.

Step 5: Click on the Next button.

Step 6: Choose the VM to import for Select Virtual Machine section.

Choose the VM to import for Select Virtual Machine section.

Step 7: Click on the Next button.

Step 8: For Choose Import Type section, choose the import option based on the requirement. In this case, we are selecting the copy option which will assign a new unique ID to the imported VM.

For Choose Import Type section, choose the import option based on the requirement. In this case, we are selecting the copy option which will assign a new unique ID to the imported VM.

Step 9: Click on the Next button.

Step 10: In the Choose Destination section, it will show the Hyper-V folders by default, but you can specify folders where the VM files should be stored. We have created a new folder and set that path by checking Store the Virtual machine in a different location option.

In the Choose Destination section, it will show the Hyper-V folders by default, but you can specify folders where the VM files should be stored. We have created a new folder and set that path by checking Store the Virtual machine in a different location option.

Step 11: Click on the Next button.

Step 12: From the Choose Storage Folders section, select the default location virtual hard disk folder or you can set a new location by manually browsing to it.

From the Choose Storage Folders section, select the default location virtual hard disk folder or you can set a new location by manually browsing to it.

Step 12: Click on the Next button.

Step 13: Verify the selections you have made in this wizard from the Summary section.

Verify the selections you have made in this wizard from the Summary section.

Step 14: Click on the Finish button.

Step 15: Files will be copied to the target location. Once the operation is complete, imported VM will be listed in the Hyper-V host in the Saved state.

Files will be copied to the target location. Once the operation is complete, imported VM will be listed in the Hyper-V host in the Saved state.

Step 16: You can start the VM by right-click on it and test that all configuration and data are available on the imported VM.

You can start the VM by right-click on it and test that all configuration and data are available on the imported VM.

Import Hyper-V VM using PowerShell

The PowerShell cmdlet used for the Hyper-V import operation is Import-VM.

Register in place

Step 1: Type the following command to delete the source VM which has the same ID:

Get-VM “VMNAME” | Remove-VM

Step 2: Type the following command to import the VM and get registered in-place and the existing unique ID:

Import-VM –Path “VM Location\Virtual Machines\VM Configuration file(.vmcx)”

Register in place method to import Hyper-V VM via PowerShell

Restore the virtual image

Step 1: Type the following command to delete the source VM which has the same ID:

Get-VM “VMNAME” | Remove-VM

Step 2: Type the following command to restore the VM:

Import-VM -Path “C:\Users\Administrator\Desktop\HYPER-V EXPORT\WINDOWS10-VM01\Virtual Machines\5AB5ED55-6BCD-44B6-88F4-AA0A5A26C1EC.vmcx” -Copy -VhdDestinationPath “C:\IMPORT-VM” -VirtualMachinePath ” C:\IMPORT-VM”

Restore VM method to import Hyper-V VM via PowerShell

Import VM as a copy

Step 1: Type the following command to import VM to the same host multiple times:

Import-VM -Path “C:\Users\Administrator\Desktop\HYPER-V EXPORT\WINDOWS10-VM01\Virtual Machines\5AB5ED55-6BCD-44B6-88F4-AA0A5A26C1EC.vmcx” -Copy -GenerateNewId

Copy method to import Hyper-V VM via PowerShell

Microsoft’s backup for VM

You can use the System Center Data Protection Manager to backup the virtual machine’s data from the host level. System Center Data Protection Manager uses block-based synchronization to take a copy of the VM. Using Hyper-V APIs, the System Center Data Protection Manager determines whether the VMs support VSS. If the VM support in VSS, the Child VM method is used to take the backup otherwise the machine is just stopped to take a snapshot.

Reference: Microsoft Docs > System Center > DPM > Use DPM to back up and restore VMware virtual machines

Third-party VM backup tool

As you may be using multiple type of hypervisors in the environment. A native backup solution for Microsoft Hyper-V doesn’t suitable when you have a mixed environment. Additionally, extensive reporting, flexible scheduling, and disaster recovery options may be needed.

Backups of Hyper-V virtual machines using third-party tool allows you to store the data in a way that has no reliance on Hyper-V infrastructure. Third-party tool allows you to restore the Hyper-V virtual machines in a disaster recovery scenario whereas Hyper-V Checkpoints don’t allow it.

Tags

Tags

    Ads Blocker Image Powered by Code Help Pro

    Ads Blocker Detected!!!

    This site depends on revenue from ad impressions to survive. If you find this site valuable, please consider disabling your ad blocker.