This article discusses the specifics of organizing virtual machine backups in the Microsoft Hyper-V environment. We’ll look at the basic requirements for Hyper-V backup solutions, backup strategies, and the main free and commercial products in this niche.
Although the Hyper-V environment offers a wide range of technologies to ensure high availability and fault tolerance of VMs (failover clusters, Live Migration, replication, etc.), the system administrator must not forget the traditional backup of virtual machines.
Methods to Backup Hyper-V Virtual Machines
Let’s look at how any modern Hyper-V virtual machine backup solution works.
There are two approaches to backing up VMs:
- Host-level VM backup – administrator manages backups at the entire Hyper-V host level;
- Backup using an agent that is installed in the guest OS (guest-level VM backup) – used quite rarely (mainly for apps that can’t be backed up properly using VSS).
All of today’s Hyper-V VM backup tools are based on the snapshot (checkpoint) technology. The checkpoint contains the state of the virtual machine at a given time and includes the virtual hard disks, the contents of the memory, and the VM settings.
Here’s a simplified example of a typical VM backup process in Hyper-V:
- The backup tool sends a command to the Hyper-V host to create a VM checkpoint;
- The hypervisor creates new delta files and the VM continues to operate. VM saves all new changes to those delta files;
- The backup program copies the original VM files (no changes are written to them) to the backup media (external drive, shared folder, tape, etc.) and then sends a command to delete the VM checkpoint;
- Hyper-V deletes the checkpoint and consolidates (merges) the original and delta files (VM operation is not interrupted).
Export-VM -Name hqman01 -Path '\\hqfs01\backup\hqman01' -CaptureLiveState CaptureSavedState
Hyper-V VM Backup: Best Practices and Requirements
This is general information about Hyper-V backup, but in reality, there are many nuances and issues. I will try to list the most common problems:
- The longer the backup tool is copying the checkpoint (backup), the more changes are logged in the delta files. If there are a large number of changes in the VM during file copying, the process of merging files when deleting a snapshot can place a heavy load on the disks, the Hyper-V host, and the VM itself. It means that it is better to copy the checkpoint as quickly as possible. Hyper-V Server 2016 (and newer) uses Resilient Changed Tracking (RCT) technology to make backups faster by copying only the blocks of data that have changed since the last backup. This eliminates the need to copy the entire VM;
- Copying VM snapshot data over a LAN network from a Hyper-V host to backup storage might cause a high network load. It is recommended to use a separate server network or HBA interface for the backup traffic or copy the data over SAN;
- If you use external data storage for VM files, you can take advantage of the storage system’s ability to integrate with backup tools (such the hardware snapshots);
- The guest operating system is initially unaware that it is being backed up. So when you try to restore a VM from this backup, the OS tries to resume operations from the moment the snapshot was created. In some cases, this can cause problems with the operating system itself and data loss in running applications (especially in transaction ones, like Exchange, SQL, ADDS, etc.). To address this issue, a new type of snapshot – the Production Checkpoint – was introduced in Hyper-V 2016 (Microsoft recommends that you only use Standard Checkpoints in test and lab environments, or to back up stopped VMs); Production checkpoints are based on Hyper-V integration services in the guest OS and the Volume Shadow Copy service (Windows) or the file system freezing daemon on Linux (fsfreeze). However, the RAM state is not copied. This means that Hyper-V notifies the guest OS that a checkpoint is being created, the app that supports VSS ends the current transactions, goes into a consistent state, and the VM checkpoint is created. When recovering from such a checkpoint, the guest OS is powered off (as the memory state has not been saved), and after being turned on it thinks that an emergency shutdown has occurred. The application in the VM (if it supports VSS) starts working from the saved consistent state.
- In order to save space on the backup storage device, it is recommended that you use deduplication. If you use Hyper-V differential disks, your backup tool must have support for this technology.
- If the density of VMs on the host is high, it is worth scheduling the backup time to avoid high loads on the production systems during working hours.
- If you have to store multiple VM copies for several days, you will have to manage the number of VM copies stored.
- Backup monitoring tools are also important. It would be frustrating to find out that you cannot back up something because there is not enough free space on the data storage.
- Some backup products support granular recovery of individual files/folders, without the need for recovery of an entire VM or its virtual disk.Note. For example, many backup solutions allow you to restore specific mailbox databases, mailboxes, and even individual emails from a VM backup with Exchange Server.
- The backup tool should allow you to configure access rights using the role-based backup management model.
- Implement the classic 3-2-1 backup strategy (three copies on two different media, one of which is stored at a remote site).
Backup Hyper-V VMs Using Windows Server Backup
You can back up your Hyper-V virtual machines by using the free, built-in Windows Server Backup (WSB) feature. WSB allows you to configure VM backup from a graphical interface or by using the wbadmin
command line tool.
You can install Windows Server Backup from the Server Manager console or using the PowerShell command:
Install-WindowsFeature Windows-Server-Backup -IncludeManagementTools
To configure a VM backup task from the GUI, open the wbadmin.msc
console.
- Expand the Local Backup and select Backup Schedule;
- Select backup type Custom -> and click Add Items;
- Expand Hyper-V and select virtual machines to backup;
- The next step is the configuration of the VM backup schedule;
- Select whether you want to save the backup to a separate disk or to a shared network folder (UNC path);
- If you are not using any other backup tools, click the Advanced Settings and enable the VSS Full Backup option.
The main disadvantage of the Windows Server Backup GUI is that you can only create a single backup task, which will overwrite any previous copies you have made. For this reason, Hyper-V administrators prefer to use the wbadmin command line tool to backup virtual machines.
List the VMs on the Hyper-V host with the PowerShell command:
Get-VM
To back up a VM named "Server 1"
to a local drive D:\
, just run this command:
wbadmin start backup –backupTarget:D: –hyperv:"Server 1"
WSB will create a snapshot for the VM and copy the virtual disks and VM state to the directory D:\WindowsImageBackup\your_HyperV_host_name
.
You can back up multiple VMs at once. In this example, we will save backup to a shared folder on a remote file server:
wbadmin start backup -backuptarget:\\192.168.1.100\VMbackup: -hyperv:"TestVM01,TestVM02" -allowDeleteOldBackups -quiet
When backing up virtual machines with a VSS-aware application (such as an AD domain controller, Exchange Server, or MSSQL), you can tell the application in the VM to update the info and flush the transaction log.
wbadmin start backup -backuptarget:\\192.168.2.15\HVMback: -hyperv:PAR-DC1 -vssFull
To automatically backup virtual machines on a schedule, you can create a job in the Windows Task Scheduler with the wbadmin command. Add the -quiet parameter to the wbadmin command to perform a backup without prompting the user.
Run the following command to get a list of the backups registered in WSB:
wbadmin get versions
Delete the oldest version of the VM backup:
wbadmin delete backup -backupTarget:c: -deleteOldest
Or you can delete one of the previous VM backups by its version name:
wbadmin delete backup -backupTarget:c: -version:11/08/2023-10:13
To restore a VM from a Windows Server backup, you need to find its identifier in the archive. List the items in the backup:
wbadmin get items -version:11/08/2023-09:33
Copy and paste the VM identifier into the following command:
wbadmin start recovery -itemtype:hyperv -version:11/08/2023-09:33 -items:70B51055-C078-B342-48BC-01518C87B4E4
The AlternateLocation and RecoveryTarget:path options allow you to restore the VM to a different location.
Windows Server Backup allows you to restore only the entire VM. You cannot restore a single drive, file, or folder. However, you can mount a backup VHDX image file to your VM and manually copy the file you need to restore.
WSB is a simple, but reliable solution for Hyper-V VM backup. It is quite fast and allows to manage the backup schedule. However, Windows Server Backup has its drawbacks:
- There is no way to monitor the backup process or to check the consistency of the VM backups;
- It is difficult to manage backup in medium and large Hyper-V installations (it is only suitable for small environments with 1-3 Hyper-V hosts);
- You cannot automatically restore a specific file or app state;
- With high density and large sizes of VMs on a host, you need to use the Windows scheduler to configure the order in which backups are created. This prevents Hyper-V server and LAN/SAN/iSCSI network overload during business hours.
Top Third-Party Hyper-V Backup Products
It is difficult to use the built-in Windows Server Backup with a large number of Hyper-V hosts and virtual machines. In this case, you will need to choose one of the backup solutions offered by third-party vendors. It is impossible to say that this or that product is the ideal solution for Hyper-V backup; there are too many nuances to consider. They include the number of hosts, licensing restrictions, required features, network architecture, etc.
Choosing the right backup product can be difficult, as there are many commercial and free backup products on the market. The Gartner Magic Quadrant is commonly used to identify niche leaders. I found this image showing the main players and leaders in the enterprise backup market in 2023.
Gartner highlights the following companies and products among the leading vendors of backup solutions:
- Commvault
- Dell Technologies
- Cohesity
- Rubrik
- Veeam (Veeam Backup Free Edition allows you to backup up to 10 VMs)
- Veritas Technologies (Symantec — Veritas Backup Exec)
- Microfocus (HPE Data Protector)
2 comments
Thanks for the detailed insight. I still have a weird effect, which I didn’t read anything about in here. I have a Hyper-V Server with two VMs on it. We use WSB. We configured it as a full backup of the Host and the VMs are selected for backup. There are no errors in the backup, but if I look into the details of the backup, I have no data transfer of the VMs. Is this normal? May the reason be, that there have been no changes on the VM?
Do you have instructions on how to restore the WSB backup of a VM?