DiskShadow / Xcopy RESTORE of Hyper-V


In my last post I showed you how to create a consistent backup of a Hyper-V host using the no additional cost Diskshadow command and an attached USB drive (in contrast to the costly VMware Consolidated Backup).  Now I want to show you how to restore the VMs that you backed up to a separate host (what good is a backup of you can’t restore it!).


To recover the data, we’ll simply reverse the process on another Hyper-V host.  I attached the USB disk used for backup to a different system, and invoked the diskshadow script below using the command diskshadow –s HyperVrestore.txt.  HyperVrestore.txt looks like this:



set context persistent
#the backup.cab file mentioned below is the one created during backup.
load metadata G:\Hypervbackup\backup.cab
set verbose on
begin restore
exec C:\HypervRestore.cmd
end restore


It’s similar the HyperVBackup.txt script, except that it reads the metadata from backup.cab and uses Xcopy (in HypervRestore.cmd) to copy the files from the USB drive (G:) to the local system:



Xcopy g:\HyperVBackup\VMs\*.* C:\VMs\*.* /e /s /y /F /O /X /R /H


The command window looks pretty similar to the one I showed you in the backup posting.


clip_image002   clip_image002[4]    clip_image002[6]


The net effect of the restore is the important part. 


On the source system, I had two running VMs (an instance of Hannah Montana Linux and a Windows Server 2003 VM):


clip_image002[10]


Before I ran the diskshadow restore, Hyper-V manager on the “recovery” system only showed three VMs:


clip_image002[8]


Once the restore process completed, the recover host showed all 5 VMs!


clip_image002[12]


Let me know if you would like me to go into more complex recovery scenarios (like different drive letters or changed drive letters / directories).


In my next post, I’ll show you some of the detailed wicked coolness of backing up non-Windows VMs using the Hannah Montana Linux instance noted above.


-John

Comments (3)

  1. Anonymous says:

    Restoring VM files to a different path is tricky…and can require (at least) some editing of the XML config file to point to some of the new file locations.  The tricker part is getting the "link" to the config (found in c:ProgramDataMicrosoftWindowsHyper-V) to point to the config file.  That all certainly would make a great blog post too…once I get through the other 400 I have to get to!

  2. Anonymous says:

    Thanks a lot for this post John.  This is the first documentation I’ve seen regarding the restoration of VMs backed up using the Diskhsadow tool and we’ve been backing up our production VMs now for close to a year.  

    Could you elaborate on restoring VMs from directories that are different from the original destinations, or could you point us to some documentation that could shed some light on this?  Thanks again for your post!

  3. David Taylor says:

    Hey John, is it possible to use DiskShadow to backup and shadows themselves?  Senario:  disk is going to fail or has bad blocks, need to move shadows to a new disk.