Hyper-V Backup and Restore

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.

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.

Backup Command

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

Restoring

Get Versions

You need the backup “version identifier” to see which items you can restore.

  • wbadmin get versions -backupTarget:F: -machine:HV01

Get Items

You need the item ID’s of what you can restore.

  • wbadmin get items -version:08/09/2016-16:18 -backuptarget:F: -machine:HV01

Restore Command

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.

Parallel Restoration

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.

  1. Make sure the backup .vhdx is not in-use.
    1. Un-mount it from any other server that might be using it, by right-clicking on it and selecting “eject”.
    2. If it’s attached in Hyper-V Manager, you can remove it live. It’s hot-pluggable both ways.
  2. Create a new Gen 2 VM in Hyper-V Manager using modified settings below:
    1. If testing, Configure Network Connection to Not Connected, Click Next.
    2. Create a new virtual hard disk, should be 150 GB, default location, click Next.
    3. Configure to Install an Operating System from .iso
      1. Should be located at: c:\iso\SW_DVD9_Windows_Svr_Std_and_DataCtr_2012_R2_64Bit_English_…
    4. Click Next, Finish.
  3. Before turning VM on, configure with typical other settings.
    1. For example, 2 logical procs, compatibility setting, etc.
  4. Attach the backup .vhdx disk to the VM.
    1. Select SCSI Controller and then Add a Hard Drive.
    2. Browse to the location of the backup .vhdx
      1. For example: F:\server-backups.vhdx .
  5. Turn on the VM, and press any key to boot to the install disk.
    1. Click Next and then click Repair your computer.
    2. Click Troubleshoot.
    3. Click System Image Recovery.
    4. Select Use the latest available… and click Next, but if the .vhdx you attached above doesn’t automatically appear:
      1. …click Select a system image and click Next.
      2. Find it, then click Next.
    5. Select the date and time you would like to restore from, then click Next.
    6. Default settings should be okay in typical circumstances. Click Next.
    7. Click Finish, then click Yes.
  6. Wait for the restore to complete.
    1. It will restart automatically.
  7. Restore process is now complete. Don’t forget to connect the network when you’re ready.

Leave a Reply

Your email address will not be published.