Backing up Hyper-V Virtual Machines

Like I’m sure many of you, I have a lab full of virtual machines.  I can’t imagine what would happen to my productivity if I had a system crash and all of those virtual systems vanished at the same time.  The answer?  backup those virtual systems.  How is the question.  It would be quite a manual process to power down and backup each system one by one.  With the introduction of Hyper-V as a core OS component I couldn’t help but believe there would be some way in the core OS to handle the backup job required.  Fortunately, my belief seems to be correct. 

Using the built in Windows backup it is fully possible to backup your Hyper-V systems – even if they are in the running state.  Windows backup will realize they are in the running state and take appropriate action before backing them up.  I’m still testing with this and I haven’t actually tried a restore (so I shouldn’t probably be writing this until I do!) but what I have so far looks like it’s doing the job. Here’s how to set it up.

The first step is to edit the registry and add some values so that windows backup knows that Hyper-V is installed and running on the system and can take appropriate action.  You will need to manually add the WindowsServerBackup reg key and all keys/values underneath as shown in the screenshot.


Next, we need to setup the backup.  Typically you would think about using the built in windows backup UI to handle this – and that will work fine.  The windows backup UI, however, only allows scheduling a job daily.  I wanted my job to run weekly so, according to the windows backu help files, my option was to set this up in task scheduler. 

To run backup through task scheduler means you will have to handle your backup from (yes, you guessed it), THE COMMAND LINE!  :)  Windows 2008 is built for command line operation so not a problem.  Launch task scheduler from the administrative tools menu and from the Task Scheduler Library right-click menu, select to create a new task (not basic task).  You will see a screen with 6 tabs for configuration. 

On the general tab, I chose to ‘run whether user is logged on or not’ and, since my backups are going to a network system, chose to allow the system to store my password for use during the task.  I then specified the account to use for running the task.


On the triggers tab i specified the schedule for the task – in my case weekly – by selecting the ‘new button’ and filling in the schedule information.



On the actions tab now, I chose to start a program – which will be my command line to use to start the backup.


image \

Some of the command line options are cut off – the list of options I used is below with some information deleted and replaced by X’s

start backup -quiet -backuptarget:\\xxxxxxxxxxx\g$\vmserver1vmbackups -include:c:,d:
-allcritical -vssFull -user:<domainorlocalsystem\account >
-password:<users password>

Those are the key settings – the remaining tabs contain some useful options as well but they are fairly self-evident.  Also, in order to restore the hyper-v image you at least need to backup the C drive – the default location for several hyper-v config files.  If you store your images on separate drives you will want to include them in the backup too.

With all of this in place, we are in the backup business and smooth sailing as far as I can tell for now.  One thing I would definately recommend – before you just setup a task and assume all is working, test your command line in the cmd window so you can see if all works.  In two cases, my command line worked fine.  In a third case i saw problems due to some specific hardware issues.  And, you really should also test if the restore works after the backup!  :)  I’ll be doing that soon.

Comments (6)

  1. News says:

    Like I&#39;m sure many of you, I have a lab full of virtual machines.&#160; I can&#39;t imagine what

  2. Very interesting. I did not think of using the VSS stuff for hyperv to do a backup even while they were running…

    I have a similar weekly backup job build with a powershell script but it basically does:

    1) "save state" all VMs

    2) triggers SyncToy to mirror the VM files (VHD, configuration, saved state, etc) to another hard disk drive

    3) starts the VMs back, eventually (I now only hardcoded the few ones that HAVE to be running at all times)

  3. Stu says:

    Great article — Questions!

    1. Can I run this script from my "host server" (the one with the hyper-v role installed)  and run several backup jobs with different machines?

    <steve>  In my lab I have 4 hyper-v servers and a single external drive I back them up to.  I configure each of my hyper-v hosts as described in the article and point them all to the single external drive.

    2. Could you explain the arguments a bit? I am trying to understand where it gets which VM to backup — I understand the backuptarget, but the rest is a bit vague.

    <steve>  Each of these items is described in detail by simply running wbadmin from a command line.

    3. How do I test my commandlets in CMD?

    <steve>  From a command prompt just run wbadmin with all of the command line options you specified and see if it works.  If you configure this in task scheduler just right click on it and select to run and see if it works.

    Again, I appreciate very much your insight and hope to hear back!

    <steve>  BTW, I updated the article slightly.

  4. Helen says:


    this is a few months old but hopefully you can help! I have read you can't backup to a remote hard drive, e.g. external drive plugged into a separate machine? It always fails for me untl I chose a hard drive attached to the local machine.

    Also, is there any way I can alter the 'include' part to include another server? It is running linux so doesn't have the Windows Server backup to set this up with…..sorry if this makes no sense!

  5. Gavinox says:


    Great article.  VSS is definitely the way to go.  However, the backups will be cripplingly large so they'll have to be done locally.  Just in case it's helpful, we've found there are one or two tools out there that combine VSS & RSync to make encrypted differential backups over the network: small and fast to a remote location.  We've been running for 2 months now & it seems stable – OK, it's 50 quid but there's a free month's trial on there.

    Hope that helps!