Having problems backing up virtual machines? This has been a problem since the beginning. Luckily, people are flocking to this issue to offer advice, help, and product solutions. Commercial, open-source, and home brewed scripting solutions are showing up on a somewhat regular basis these days.
Here is another option from Chris Wolf, check out the article on MCPmag, here:
For those of you running Virtual Server 2005, there is no way to back up a hot VM without running a back-up agent inside the VM. However, one alternative that you may consider would be to suspend the VM, back up its related files, and then resume the VM following the completion of the backup. Here’s a VBscript that gets the job done:
Option Explicit
'Declare variables
Dim strVMName, strVMFolder, strToday
Dim strBackupFolder, strBackupFile
Dim strJobName, strDescription, strNTBackupCommand
Dim objVirtualServer, objVirtualMachine, objShell, errBackup
'Load current date (formatted as mm-dd-yyyy)
'into variable strToday
strToday = Month(Date) & "-" & Day(Date) & "-" & Year(Date)
'Define Script Variables
strVMName = "W2K3-DC1"
strVMFolder = """E:\VMs\W2K3-DC1"""
strBackupFolder = "F:\Backup\VMs"
strBackupFile = Chr(34) & strBackupFolder _
& "\" & strVMName & "_" & strToday _
& ".bkf" & Chr(34) 'Chr(34) is used to
'include a quote in the string
strJobName = Chr(34) & strToday & " Full Backup" & Chr(34)
strDescription = Chr(34) & "Starting " & strToday &Chr(34)
strNTBackupCommand = "ntbackup backup " & _
strVMFolder & " /J " strJobName & " /D " & _
strDescription & " /F " & strBackupFile
'Instantiate Virtual Server Object
Set objVirtualServer = _
CreateObject("VirtualServer.Application")
'Instantiate Virtual Machine Object
Set objVirtualMachine = _
objVirtualServer.FindVirtualMachine(strVMName)
'Save VM State
objVirtualMachine.Save()
'Instantiate command shell object
Set objShell = WScript.CreateObject("Wscript.shell")
'Use ntbackup.exe to back up saved VM
errBackup = objShell.Run(strNTBackupCommand,1,True)
'Restart VM
objVirtualMachine.Startup()
Note that the script backs up the VM’s files using NTbackup.exe; however, you could modify the script to work with your existing back-up product.