Microsoft Virtual Server 2005 backup script

John Savill published for WindowsITPro a Visual Basic Script useful for backup of Virtual Server 2005 virtual machines, suspending, copying and resuming (which will be no more needed from Virtual Server 2005 R2 Service Pack 1 featuring live backup):

‘ backupvm.vbs
‘ John Savill
‘ Usage : backupvm.vbs
‘ e.g. cscript backupvm.vbs savdalum01 c:\backup’ Make sure that you place the \ at the end of the backup path or you’ll get errors.

Option Explicit
On Error Resume Next

Dim objFSO, objVirtualServer, objVM, objSaveTask, objVHD

‘Connect to file system object.
set objFSO=CreateObject(“Scripting.FileSystemObject”)

‘Connect to Virtual Server.
set objVirtualServer = CreateObject(“VirtualServer.Application”)

‘Get virtual machine from command-line parameter.
set objVM = objVirtualServer.FindVirtualMachine(WScript.Arguments(0))

‘Save state of the virtual machine.
set objSaveTask = objVM.Save

‘Loop waiting for task completion
while not objSaveTask.isComplete
WScript.Sleep 1000

‘Copy virtual hard disks and undo disks.
for each objVHD in objVM.HardDiskConnections
If objFSO.FileExists(objVHD.HardDisk.file) Then
‘Wscript.Echo objVHD.HardDisk.file & ” ” & WScript.Arguments(1)
objFSO.CopyFile objVHD.HardDisk.file, WScript.Arguments(1)
End If
If objFSO.FileExists(objVHD.undoHardDisk.file) Then
‘Wscript.Echo objVHD.undoHardDisk.file & ” ” & WScript.Arguments(1)
objFSO.CopyFile objVHD.undoHardDisk.file, WScript.Arguments(1)
End If

‘Copy .vmc and .vsv files.
objFSO.CopyFile objVM.File, WScript.Arguments(1)
objFSO.CopyFile objVM.SavedStateFilePath, WScript.Arguments(1)

‘Start the virtual machine.

Read the original article for update and comments.

Thanks to for the news.