Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


March 13, 2006

Q. How can I back up a virtual instance running in Microsoft Virtual Server 2005?

RSS
Subscribe to Windows IT Pro | See More Backup and Recovery Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

A. To safely back up a virtual instance, you first need to suspend it, then copy its disk files, saved memory, and configuration to the backup location, then restart it. To enable this process via a scheduled task or command line, you use the Virtual Server 2005 COM interface. The script, backupvm.vbs, which you can download here, demonstrates the process.


' 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
wend

'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
Next

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

'Start the virtual machine.
objVM.Startup

To use the script, simply pass the virtual machine (VM) name as the first argument and the folder to which to copy the backup data as the second argument, as the following example shows:


C:\temp>cscript backupvm.vbs savdalum01 c:\backup
This example backs up the instance savdalum01 to folder c:\backup.

End of Article



Reader Comments
Didn't your commented-out instructions say to include the \ at the end of the path? Your example doesn't do this. Am I misunderstanding this?

Thanks,

John

jjl@uci.edu March 15, 2006 (Article Rating: )


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: 4th of July Special Edition

An often irreverent look at some of the week's other news, including a shortened work week thanks to the 4th of July, expensive Windows 7 pricing, Bing's modest monthly gains, IE 8 heading to work, Steve Jobs back at Apple, and so much more ...

Google Wave Emulates Trends of Changing World

As collaboration continues to increase, the world and how individuals view information is evolving. What does that mean for IT? ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events WinConnections and Microsoft® Exchange Connections

Learn How to Solve your Toughest Storage Challenges... In Just 6 Minutes or Less

Continuous Application Virtualization: An Answer to Exchange Recovery Problems

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format

Test Drive IT Solutions and Get Free Music Downloads
Solve your toughest IT problems with these free downloads and receive 5 free music downloads!


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home asp.netPRO Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement | Reprints and Licensing