When it comes to choosing a backup solution for your on-premises servers which is one of the key workloads still for many organizations, you have many options to choose from, this could also differ based on different scenarios and requirements.
In this article, we will show you how to protect and backup Hyper-V VM to Azure Backup with the MARS agent.
In This Article
When designing either a backup or disaster recovery solution, you need to assess first the workloads to understand what is important to your organization, and to prioritize the importance of the workloads by performing a Business Impact Analysis (BIA) which is the first step in the business continuity planning process.
Next, you start addressing what level of protection each of your workloads needs by estimating the maximum allowable downtime, as well as the acceptable level of losses (i.e. what is the impact if you lost an hour versus a week’s worth of data?) Then you start designing your recovery solutions based on the impact analysis which is a huge task that must be undertaken by coordinating with various business functions and processes.
If you are familiar with Microsoft Business Continuity and Disaster Recovery (BCDR) solutions, you may know the different solutions and products which are available to use based on your organization’s needs.
In this article, we will focus on protecting and backing up Hyper-V VM running on-premises to Azure Backup with the MARS agent and then verify the restoring process.
Azure Backup (MARS)
MARS is a standalone agent which is used by Azure Backup to back up your files, folders, and system state from on-premises individual machines and Azure IaaS VMs to Recovery Services Vaults in Azure.
You can deploy and run the MARS agent in three different scenarios as follows:
1) Run the agent directly on-premises on Windows machines so that they can back up directly to Recovery Services Vaults in Azure. You can choose the MARS agent as a backup solution to protect your file server in the cloud for long-term retention.
2) Run the agent on Azure IaaS VMs running Windows (side-by-side with the Azure VM backup extension) to back up specific files and folders on the VM.
3) Run the agent on Microsoft Azure Backup Server (MABS) or System Center Data Protection Manager (SCDPM) server. In this scenario, the workload will be backed up to MABS/SCDPM first, and then MABS/SCDPM will transfer your backup to Recovery Services Vaults in Azure using the MARS agent. So, what you can back up depends on where the agent is installed.
A new and interesting scenario is, what about if you don’t have the proper hardware and infrastructure on-premises to install the Microsoft Azure Backup Server (MABS) or System Center Data Protection Manager (SCDPM) to protect Hyper-V VMs? What about if you are short on budget?
The good news is, that you can also use the MARS agent as a backup solution to protect on-premises Hyper-V servers in the cloud for long-term retention. At the time of this writing, this scenario is NOT yet officially supported as documented by Microsoft. However, with a small workaround and a bit of planning as we will describe in the next section, we can protect and back up a small Hyper-V deployment to Azure Backup.
If you still have a large Hyper-V deployment running on-premies, then you need to look at Microsoft Azure Backup Server (MABS), System Center Data Protection Manager (SCDPM), or other third-party commercial solutions.
To follow this article, you need to have the following:
1) Azure subscription – If you don’t have an Azure subscription, you can create a free one here.
2) Windows Server Hyper-V 2012 R2 or later version running (standalone host and NOT cluster). Please note that the MARS agent does NOT support Windows Server/Hyper-V Core SKUs. You need Windows Server with Desktop Experience SKU.
3) At least one Azure Recovery Services vault is created. Please check the following quick start guide to create and configure a Recovery Services vault. Make sure after you create the Recovery Services vault to modify the storage replication from geo-redundant storage (GRS) to locally redundant storage (LRS) to reduce Azure storage costs.
4) Download the latest MARS agent from the following location and install it on your Windows Server Hyper-V host. At the time of this writing, we are using version 2.0.9226.0.
5) Verify internet access on your Windows Server Hyper-V by checking the URL and IP access as documented by Microsoft. The MARS agent requires access to Azure Active Directory, Azure Storage, and Azure Backup service endpoints.
6) Download the vault credentials from the Recovery Services vault and register the MARS agent to the vault as documented by Microsoft. Please make sure to save the passphrase in a secure location. You need it to restore a backup. If you lose or forget the passphrase, Microsoft can’t help you recover the backup data.
Assuming you have all the prerequisites in place, take now the following steps:
Backup Hyper-V VM in Windows Server Backup
To back up a Hyper-V VM to Azure Backup, it’s a two steps process:
1) First, we must schedule and back up the virtual machine using Windows Server Backup locally on an NTFS volume.
2) Second, schedule the backup with MARS to Azure Recovery Services Vault. As noted earlier, the MARS agent does not support backing up Hyper-V VMs natively yet.
The built-in Windows Server Backup (WSB) feature integrates with the MARS cloud backup in the same console as shown in the figure below.
We can use WSB via the graphic backup/restore wizard or the (wbadmin.msc) command-line tool (which is a part of WSB). Windows Server Backup supports VSS and incremental backup. This feature is available both on Windows Server 2012 (and newer) and on Hyper-V Server.
To install the Windows Server Backup (WSB) component, go to the Server Manager console, Windows Admin Center, or run the following command:
Install-WindowsFeature Windows-Server-Backup -IncludeManagementTools
Windows Server Backup has the GUI console (wbadmin.msc) that allows to create and manage Hyper-V backups, create a backup schedule, etc. To back up a VM, just start the simple wizard, select custom as backup configuration, and then add which VMs from your Hyper-V server have to be backed up as shown in the figure below. The VM will be protected as (Online), which means that any virtual machines included in the backup WON’T be temporarily placed into a saved state when the backup runs.
As a side note, make sure to keep the default VSS copy Backup and do not use VSS full Backup. Because when you do a VSS full backup, you create a backup of all the files – but after that, the backup application may truncate logs on the file system. On the other hand, when you do a VSS copy Backup, all files are backed up and you preserve all the applications files including log files on the live system. That means you do preserve information on which files were changed, deleted, etc, and this will not affect the sequence of incremental and differential that might happen independently of the copy backup.
Next, specify the backup time for the selected VM (in this example, once a day at 9:00 pm). It is important to plan the WSB backup schedule to be completed first (non-overlap) before Azure Backup starts the backup (more on this in the next section).
In this case, the WSB engine will backup the VM locally at 9:00 pm and the Azure Backup engine will start at 4:00 am, you might need to adjust the schedule a bit to fit the size of your VM. The good news is, starting in Windows Server Hyper-V 2016 and later version, the Resilient Changed Tracking (RCT) technology is used to make backup faster due to copying only the blocks of data changed since the last backup. Windows Server Backup (WSB) also benefits from RCT assuming your virtual machine configuration version is at v8.0 or later.
Next, choose the destination type where the backups are to be saved, the backup should be stored locally on a different volume (choose Backup to a volume). Choose this option if you cannot dedicate an entire disk for backups. Note that the performance of the volume may be reduced by up to 200 percent while it is used to store backups. We recommend that you do not store other server data on the same volume.
Next, select the destination volume as shown in the figure below, click Next and finally click Finish and then Close.
Please note that it’s important to save the backup locally on an NTFS volume and not on ReFS. Because at the time of this writing, Azure Backup (MARS agent) does NOT support ReFS volumes as documented by Microsoft, nor Network share.
Usually, it is easier to use the command prompt to backup a Hyper-V VM. Moreover, you cannot create more than one VM backup task in the graphic interface (UI), and the task will overwrite all previous backup tasks. Additionally, you cannot specify for how long (data retention) you want to keep the backup. By using the Windows Server Backup (WSB) graphic interface, the backup will remain on your disk and soon you will run out of disk space if you don’t clean manually the previous backup.
We highly recommend adding the following command to the Windows Task Scheduler using PowerShell and thus schedule regular VM backups, and by adding -allowDeleteOldBackups parameter (older backups will be removed and deleted in this case automatically).
To back up a VM named “VM01 and VM02” to a local volume on disk D, just add this command:
wbadmin start backup -backuptarget:D: -hyperv:"VM01,VM02" -allowDeleteOldBackups -quiet
Once Windows Server Backup (WSB) completed the backup, you will see a new folder called (WindowsImageBackup) created on the destination volume for backup. Note the location of the folder, we will use it in the next section.
If you open the Backup folder, you will see the entire virtual hard disk file for the virtual machine.
Backup Hyper-V VM to Azure Backup
Now, we are ready to back up the VHDX file of the Hyper-V VM to Azure Backup with the MARS agent.
First, we start by creating a backup policy.
The backup policy specifies when to take snapshots of the data to create recovery points. It also specifies how long to keep recovery points. You use the MARS agent to configure a backup policy.
Please note that Azure Backup doesn’t automatically take daylight saving time (DST) into account. This default could cause some discrepancy between the actual time and the scheduled backup time.
To create a backup policy:
1) After you download and register the MARS agent, open the (wbadmin.msc) console. Or you can find it by searching your machine for Microsoft Azure Backup.
2) Under Actions, select Schedule Backup as shown in the figure below.
3) In the Schedule Backup Wizard, select Getting started, and then click Next >.
4) Under Select Items to Backup page, select Add Items.
5) In the Select Items box, select the (WindowsImageBackup) folder as shown in the figure below, this is where Windows Server Backup is backing up the VHDX, and then select OK. Please note that you can only select NTFS volumes and not ReFS.
6) On the Select Items to Backup page, select Next >.
7) On the Specify Backup Schedule page, specify when to take daily or weekly backups. Then select Next >.
> A recovery point is created when a backup is taken.
> The number of recovery points created in your environment depends on your backup schedule.
> You can schedule up to three daily backups per day. In the following example, one daily backup occurs at 4:00 AM. Remember to plan the WSB backup schedule to be completed first (non-overlap) before Azure Backup starts the backup. You can run weekly backups too. In this example, we need to back up the VM (VHDX) file daily.
8) On the Select Retention Policy page, specify how to store historical copies of your data. In this example, we are interested to retain the backup daily for 14 days only. Retention settings specify which recovery points to store and how long to store them.
For a daily retention setting, you indicate that at the time specified for the daily retention, the latest recovery point will be retained for the specified number of days. Then select Next >.
9) On the Choose Initial Backup Type page, decide if you want to take the initial backup over the network online or use offline backup. To take the initial backup over the network, select Online (transfer over the network) as shown in the figure below. Click Next >.
For more information about offline backup, check Use Azure Data Box for offline backup.
10) On the Confirmation page, review the information, and then select Finish.
11) After the wizard finishes creating the backup schedule, select Close.
Last but not least, you need to create a policy on each Hyper-V host where the MARS agent is installed.
On the next schedule, the MARS (obengine) will start and push the VHDX files to Azure.
You can also run backup up on-demand by using the Back Up Now option of the MARS agent to test the entire process. In this example, the backup is completed and transferred 41 GB (compressed and includes meta-data) to Azure as shown in the figure below. The good news is, in this example, the original folder size of the (WindowsImageBackup) is 74 GB, MARS agent compressed the VHDX file and sent only 41 GB.
Restore VHDX file from Azure
This section explains how to restore Hyper-V VM (VHDX) files from the Azure Backup vault. Once the backup to Azure is completed, you could use Instant Restore capability to recover data to the same Hyper-V host or an alternate machine.
To restore data, you use the Recover Data wizard in the Microsoft Azure Recovery Services (MARS) Agent. You can:
> Restore data to the same machine from which the backups were taken.
> Or, restore data to an alternate machine.
If you lose your virtual machine on-premises and want to restore it to the same Hyper-V host (from which the backup is taken), the following steps will help you recover the data.
1) Open the Microsoft Azure Backup snap-in. If you don’t know where the snap-in was installed, search for Microsoft Azure Backup.
2) Select Recover Data to start the wizard as shown in the figure below.
3) On the Getting Started page, to restore the data to the same Hyper-V server, select This server (<server name>) as shown in the figure below, and then click Next >.
4) On the Select Recovery Mode page, choose Individual files and folders, and then click Next >.
Please note that the Individual files and folders option allows for quick access to the recovery point data. It’s suitable for recovering individual VHDX files and is recommended for a total size up to 80 GB as documented by Microsoft. It offers transfer or copy speeds up to 6 MBps during recovery.
The second option Volume recovers all backed-up data in a specified volume. This option provides faster transfer speeds (up to 40 MBps) and is recommended for recovering large-sized VHDX or entire volumes. In this example, the VHDX of the VM is less than 80 GB.
5) On the Select Volume and Date page, select the volume that contains the files and folders you want to restore.
On the calendar, select a recovery point. Dates in bold indicate the availability of at least one recovery point. If multiple recovery points are available within a single date, choose the specific recovery point from the Time drop-down menu.
After choosing the recovery point to restore, select Mount as shown in the figure below. Azure Backup mounts the local recovery point and uses it as a recovery volume. This might take a few minutes to complete.
6) On the Browse and Recover Files page, select Browse as shown in the figure below to open Windows Explorer and find the VHDX files you want.
7) In Windows Explorer, copy the VHDX files you want to restore, and paste them to any location local to the Hyper-V server. You can open or stream the files directly from the recovery volume, and verify that you’re recovering the correct versions.
As a Tip: Use Robocopy for better performance instead of Windows Explorer when copying files from the recovery volume into a destination of your choice (example command syntax below). Refer to https://aka.ms/bkprobocopy for more information.
robocopy E:\WindowsImageBackup D:\WindowsImageBackup /Copyall /S /E /dcopy:T /b /R:3 /W:1 /Log:C:\robocopy-log.txt /NP
8) When you’re finished, on the Browse and Recover Files page, select Unmount. Then select Yes to confirm that you want to unmount the volume.
Please note that if you don’t select Unmount, the recovery volume will remain mounted for 6 hours from the time when it was mounted. However, Microsoft extended the mount time to a maximum of 7 days in case of an ongoing file copy. No backup operations will run while the volume is mounted. Any backup operation scheduled to run when the volume is mounted will run after the recovery volume is unmounted.
For more information on using Instant Restore to restore the VHDX file to an alternate machine, please check the following step-by-step guide.
Once the VHDX file is restored from Azure, you can recreate the VM on-premises and attach the virtual hard disk.
That’s it there you have it!
Windows Server Backup (WSB) is a simple, but reliable solution for Hyper-V VM backup. It is quite fast and allows to manage the backup schedule. It is suitable only for small environments with 1-3 Hyper-V hosts, and by integrating it with Azure Backup (MARS) agent, you make sure your data is protected off-site for business continuity and disaster recovery especially for small and branch office scenarios.
- Take a look at the Azure Backup (MARS) agent in more detail.
Azure Backup is a cloud-based backup solution that is part of a broad service presented to customers through Azure Recovery Services Vaults. Though cloud-native and platform as a service (PaaS), it is also possible to use Azure Backup on-premises as well as in the cloud. Azure Backup can replace your existing on-premises and off-site backup solution with a cloud-based solution that is reliable, secure, and cost-competitive.
Azure Backup is simple to configure and use, offering consistent copies with security features and management controls via the Azure portal:
- Learn more on how Azure Backup Integrates with Azure File Sync – Part I
- Learn more on how Azure Backup Integrates with Azure File Sync – Part II
We hope this article gave you a broad overview of how to use Azure Backup (MARS) agent to protect on-premises Hyper-V to help you move your off-site backup and long-term retention to the cloud while minimizing operations overhead, reducing licensing and hardware costs, and increasing data protection against security threats.
Thank you for reading my blog.
If you have any questions or feedback, please leave a comment.