I have been working with a couple of clients recently who have been running Team Foundation Server as a virtual machine on Microsoft Virtual Server 2005 R2 w/SP1.
Recently I had a client ask me about how to backup the running virtual machine(s) and my most common answer to date is to use a scheduled task to call a vbs script to shutdown the virtual machine, copy the VHD file to an alternate server and the restart the virtual machine. There are several derivatives of this solution including suspending, using differencing disks and more.
Now there’s a better answer….
With the recent release of Microsoft System Center Virtual Machine Manager (SCVMM) we have a number of new features that are perfect for the task of backing up the running virtual machines. Firstly, SCVMM includes a Powershell snapin that makes working with Virtual Server 2005 a breeze. It was never what I would call fun in the past trying to use the COM interfaces with VBScript. Secondly, SCVMM includes built-in support for P2V (Physical-to-Virtual) or in our case V2V (Virtual-to-Virtual) duplication of running servers. For the best solution, have Virtual Server 2005 running on a second (backup) server and copy your TFS virtual machine over to the second server. That way if anything catastrophic happens to your primary TFS server, you can just start the backup VM.
WOW – Does it get any better than this?
It sure can! The P2V wizard allows you to easily create a job to duplicate the running TFS virtual server. As one of the final steps of the wizard you can choose to show the Powershell script that the wizard generates to achieve the P2V. Simply copy this to a file (.ps1) and you can edit the actions to do a few more important things. In my case, add error handling, gather some performance metrics and include email reporting of the success or failure of the P2V (V2V) job.
Scheduling the V2V backup
Now that we have generated the Powershell script and edited it to add a few more steps, the next step involves creating a new scheduled task to execute the script. The backup task can be done any time as the P2V can occur on a running virtual machine without taking the server offline. It’s still a good idea to run the script during a quiet time such as 4am each day.
The command to execute from the scheduled task is;
C:WINDOWSSystem32WindowsPowerShellv1.0powershell.exe -nologo –noninteractive &’C:PS ScriptsbackupTFSVM.ps1’
Test the solution out by manually running the Powershell script and making sure the duplicate appears on your backup Virtual Server.
The bigger picture
The solution outlined above works well where you are using the P2V script to duplicate the TFS virtual server from one host machine to a backup host machine, also running Virtual Server 2005. In the event of a failure of the primary virtual machine or virtual server host, you can simply run up the duplicate copy of the machine and take steps to ensure the original virtual machine does not start up.
A few caveats
- This solution offered some of my clients a number of benefits specific to their needs. In every occasion, this solution is NOT their primary backup solution.
- There are existing commercial products on the market that do the things detailed above in a far more sophisticated way, more suited to enterprise customers. (Albeit at a much higher price)
-
The V2V solution can also be easily adapted to allow easy testing of patches and configuration changes using the duplicate to test these in an isolated network.</ul>
If you’re interested in trying this out yourselves, here are a few links to help you get started.
-
Microsoft Virtual Server 2005 R2 (Make sure you’re using R2 with SP1 to get the hardware assist & enhanced support)