Project Description


The main goal of this project is to provide a very easy and powerful free tool to backup and restore Hyper-V virtual machines, in standalone and clustered (CSV) environments, overcoming all the limitations that a generic tool like Diskshadow provides.

This tool targets Windows 2008, Windows 2008 R2 and Windows Server 2012. All the corresponding core and free Hyper-V editions are also supported!

HVBackup supports app consistent and crash consistent backups through the Hyper V VSS writer component integrated in the operating system.

There are quite a few expensive commercial solutions on the market supporting this scenario, but this is the first open source one, based on the research we did before publishing the project.

We integrated this tool in our datacenter's production environment management infrastructure, which means that it undergoes continuous testing in a real world environment :-)

HVBackup can be invoked from the command line, scripted with Powershell or integrated in any .Net program through it's class library.

The backup process generates a separate zip file for each virtual machine in the specified output directory, containing all the files owned by the VM and identified for backup by the VSS Hyper-V provider.

Requirements:

.Net Framework 3.5, which can be easily enabled on the command line.

Windows Server / Hyper-V Server 2012, in Powershell:

Install-WindowsFeature NET-Framework-Core

Windows Server 2008 / 2008 R2 (non core):

ocsetup NetFx3

Windows Server (core) / Hyper-V Server 2008 / 2008 R2:

ocsetup NetFx3-ServerCore


Alessandro Pilotti
MVP ASP.Net / IIS

MVP_Horizontal_FullColor_small.png
Follow alexpilotti on Twitter

Usage samples

HVBackup -a -o c:\backup

Performs a full VSS backup (using the HyperV VSS writer) of all VMs on the host.

HVBackup -l "VM1,VM2" -o \\yourserver\backup

Performs a full VSS backup of the provided list of VMs (use quotes if the names contain spaces).
In this sample the output directory is on a remote server.

HVBackup -f list.txt -o c:\backup

Performs a full VSS backup of the VMs names provided in "list.txt", one per line.

How to perform a scheduled backup

Create a batch file, e.g.: backup.cmd with the followind content:

set BCKPATH="\\yourserver\yourpath"

rem net use %BCKPATH% /user:<user> <password>

pushd %BCKPATH% && forfiles.exe -m *.zip -d -7 -c "cmd /c del @path"
popd

HVBackup.exe -a -o %BCKPATH% 1> lastlog_out.txt 2> lastlog_err.txt


Note: This script will delete every zip file older than 7 days in the target directory before performing a backup of all the VMs on the host. Change it accordingly to your needs.

Now, as we don't have a scheduled task UI on hyper-v or server core, in order to schedule the previous script every night at 01 AM, just run:

schtasks.exe /create /tn HVBackup /tr c:\hvbackup\backup.cmd /sc DAILY /ru <username> /rp /st 01:00:00


To delete the task:

schtasks.exe /delete /tn HVBackup /f


To run the task now:

schtasks.exe /run /tn HVBackup


Command line reference

Usage: HVBackup.exe [options]



-b, --backup

Performs a backup (default).

-r, --restore

Performs a restore.

-f, --file

Text file containing a list of VMs to backup, one per line.

-l, --list

List of VMs to backup, comma separated.

-a, --all

Backup all VMs on this server (default).

-n, --name

If set, VMs to backup are specified by name (default).

-g, guid

If set, VMs to backup are specified by guid.

-o, --output

Required. Backup ouput folder. Can be a local or an UNC path (e.g. \\yourserver\backup\path).

--outputformat

Backup archive name format. {0} is the VM's name, {1} the VM's GUID and {2} is the current date and time. Default: "{0}_{2:yyyyMMddHHmmss}.zip"

-s, --singlevss

Perform one single snapshot for all the VMs.

--help

Displays the help screen.

HyperVBackup.png

TODO

The backup features in the current project status are stable.

Here's a brief list of features that need to be implemented / fixed.

  • Restore
  • Differential backups
  • Windows 8 remote CSV backup component support
  • Provide missing feature in DotNetZip to include volumes in absolute paths
  • Correct bugs in the CommandLine options library

Last edited Mar 14 at 9:21 PM by alexp, version 45