Many of you have asked how you can back up your Virtual Machines running on Virtual Server 2005.
One of the suggestions is as Virtual Server has an open scriptable interface that you use a script to put all of your Virtual Machines in to a Saved State, backup the .vhd, .vmc, undo and save state files and then restore your machines.
This script takes two command line parameters - the first one being the name of the virtual machine to backup, while the second one is the name of the path to backup to:
'Script BeginsOn Error Resume Next'Create Shell ObjectSet objShell = CreateObject ("WScript.Shell")'Connect to Virtual ServerSet virtualServer = CreateObject("VirtualServer.Application")'Get virtual machine from command-line parameterset vm = virtualServer.FindVirtualMachine(WScript.Arguments(0))'Save state the virtual machineset saveTask = vm.Save'Loop waiting for task completion - and display statuswhile not saveTask.isComplete WScript.Sleep 1000wend'Copy virtual hard disks and undo disksfor each vhd in vm.HardDiskConnections objShell.Run "%comspec% /c copy " & chr(34) & vhd.undoHardDisk.file & chr(34) & " " & chr(34) & WScript.Arguments(1) & chr(34),1 , True objShell.Run "%comspec% /c copy " & chr(34) & vhd.HardDisk.file & chr(34) & " " & chr(34) & WScript.Arguments(1) & chr(34),1 , Truenext'Copy .VMC and .VSV filesobjShell.Run "%comspec% /c copy " & chr(34) & vm.File & chr(34) & " " & chr(34) & WScript.Arguments(1) & chr(34),1 , TrueobjShell.Run "%comspec% /c copy " & chr(34) & vm.SavedStateFilePath & chr(34) & " " & chr(34) & WScript.Arguments(1) & chr(34),1 , True'Once everything is done - startup the virtual machinevm.Startup'Script ends
Let me know how you get on.
Source: http://blogs.msdn.com/virtual_pc_guy/archive/2005/02/25/380216.aspx