In this post, I will be going over Hyper-V backup and restore. We’ll back up and restore Hyper-V virtual machines using Windows Server Backup WSB and command line CLI, to and from iSCSI and a .VHDX located on a network drive.
Table of Contents
Windows Server Backup
Hyper-V backup, in many circumstances, can be nicely backed up using Windows Server Backup, without the need for expensive third-party software.
The following command will, from the Hyper-V hypervisor (HV01), back up a Hyper-V VM named “serv-WEB1” to the F: drive without prompting for a yes/no. In this case, the F: drive is an iSCSI device.
- wbadmin start backup -backupTarget:F: -hyperv:serv-WEB1 -quiet
You need the backup “version identifier” to see which items you can restore.
- wbadmin get versions -backupTarget:F: -machine:HV01
You need the item ID’s of what you can restore.
- wbadmin get items -version:08/09/2016-16:18 -backuptarget:F: -machine:HV01
With the above information you obtained, you now have the required info to restore a VM or other item.
- NOTE: When you restore a VM from backup, it will delete the existing VM if it exists on the same server you are restoring it to!
- wbadmin start recovery -version:<version> -itemType:hyperv -items:<serverName> -backuptarget:F: -machine:HV01
- In this example, we’d replace <serverName> with “serv-Web1” to restore a VM named serv-Web1, using the version identifier you found.
Use the following options to restore a VM to an alternate location if you, for example, need to recover a file. This method will not delete the existing VM.
- Add the -recoveryTarget: switch to the above restore command, and make sure it points to somewhere different than the real VM.
- Use -recreatePath to re-create folder structure in the recoveryTarget path / restore path you choose.
Restoring from Backup located on a .VHDX virtual disk
This process guides you through restoring from a backup located on a .VHDX virtual disk, may be hosted on some network share.
- Make sure the backup .vhdx is not in-use.
- Un-mount it from any other server that might be using it, by right-clicking on it and selecting “eject”.
- If it’s attached in Hyper-V Manager, you can remove it live. It’s hot-pluggable both ways.
- Create a new Gen 2 VM in Hyper-V Manager using modified settings below:
- If testing, Configure Network Connection to Not Connected, Click Next.
- Create a new virtual hard disk, should be 150 GB, default location, click Next.
- Configure to Install an Operating System from .iso
- Should be located at: c:\iso\SW_DVD9_Windows_Svr_Std_and_DataCtr_2012_R2_64Bit_English_…
- Click Next, Finish.
- Before turning VM on, configure with typical other settings.
- For example, 2 logical procs, compatibility setting, etc.
- Attach the backup .vhdx disk to the VM.
- Select SCSI Controller and then Add a Hard Drive.
- Browse to the location of the backup .vhdx
- For example: F:\server-backups.vhdx .
- Turn on the VM, and press any key to boot to the install disk.
- Click Next and then click Repair your computer.
- Click Troubleshoot.
- Click System Image Recovery.
- Select Use the latest available… and click Next, but if the .vhdx you attached above doesn’t automatically appear:
- …click Select a system image and click Next.
- Find it, then click Next.
- Select the date and time you would like to restore from, then click Next.
- Default settings should be okay in typical circumstances. Click Next.
- Click Finish, then click Yes.
- Wait for the restore to complete.
- It will restart automatically.
- Restore process is now complete. Don’t forget to connect the network when you’re ready.