Home
Categories: Hyper-V, Windows Server Posted by Tore Lervik on 9/3/2009 8:58 PM | Comments (5)

One of my first posts here on my blog was about the two PowerShell scripts that I made for taking snapshots and backup of Virtual Machines. It was a simple script, but alot of people seemed to like them. Time has passed, and iv'e changed how I want to perform my backups.

How to configure Windows Server Backup

  1. Install the Windows Server Backup feature with Server Manager, and make sure you include the command-line tools available.
  2. Add this string to the registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WindowsServerBackup\Application Support\{66841CD4-6DED-4F4B-8F17-FD23F8DDC3DE}\Application Identifier\Hyper-V
    Link: http://support.microsoft.com/kb/958662
  3. Restart the server
  4. Start Windows Server Backup and create a new schedule.
    Select C: and the volume you have your VM's on. (Do not select .vhd files directly, apparently VSS doesn't like that)
    Select a dedicated backup location. (The backup will fail under schedule if you select a normal volume)
  5. Try to run the backup once, it should run without fail. :)

(Bonus) Monitor your backup in case of an error

A backup is no good if you don't get notified if there was an error. It's a classic when companies find out that their backup solution stopped working 6 months ago, just when they needed the backup.
I've created a new simple PowerShell script that checks the last successfull backup. The script will send an email if the last successfull backup is older than a given amount of hours.
Configuration is in the start of the script. By default the script will check if last backup is older than 24 hours, and it will also send a "backup succeded" mail.

BackupCheck.ps1 (1.04 kb)

To configure a schedule for the script to run, start Task Scheduler and create a new task.
Under Action, click Add and enter Powershell as program and "& 'C:\Hyper-V\BackupCheck.ps1'" as argument.
Under Triggers, click Add and enter your desired intervall. I've set mine to run 2 hours after the backup schedule.

With this you should be able to have a pretty good overview over your backup :) 

Comments

Karol Stilger on 9/10/2009 5:35 PM Hi Tore, I will try to test your hint in my testing environment. Looks very nice!
Karol Stilger on 9/14/2009 12:11 PM One more thingSmile Restart in not required in this scenario. WSB is watching for this registry key during backup creation.
Jonathan Cohen on 10/8/2009 5:45 PM You said ...

Time has passed, and iv'e changed how I want to perform my backups.

Why the change of heart? Is this new technique a best practice?
Tore Lervik on 10/8/2009 6:25 PM Hi Jonathan,

This way allows me to run backup without halting the VM's. And with my PowerShell script I get notified if a problem occurs.
Best practice when it comes to backup is really about addressing your needs. But this way uses VSS just like any other enterprise backup solution, it just got less options and features.
Robert Vabo on 1/19/2010 8:31 AM If you get a security warning when You run the script you have to set ExecutionPolicy. Start PowerShell in admin mode and run the command Set-ExecutionPolicy Unrestricted (or a stronger policy if you want).

To run the script directly and bypass restrictions you can add powershell.exe as the program to run and add the following commandline -ExecutionPolicy Bypass -File d:\BackupCheck.ps1

Add comment




biuquote
Loading