Re: virtual server backups



thank you so much for your response... i thought no one would answer this
question.

i do have a script in mind, but for some reason it only saves .vmc and .vsv.
Here is the script. Can you tell me where i'm going wrong and why it isn't
saving my .vhd.

thanks so much for your help.

***********vb script begins**********
On Error Resume Next

Set objShell = CreateObject ("WScript.Shell")
set objFSO=CreateObject("Scripting.FileSystemObject")
Set virtualServer = CreateObject("VirtualServer.Application")
DestBackupDir = "your backup path"
sExCmd = "CreateVSS.cmd"
Set oFileSys = CreateObject("Scripting.FileSystemObject")
if oFileSys.FileExists(sExCmd) then oFileSys.DeleteFile(sExCmd)
set oExCmd = oFileSys.CreateTextFile(sExCmd, CopyOverwrite)

For each objVM in virtualServer.VirtualMachines
'See if vm machine is running. If so then do backup
If objVM.State = 5 then
'Save state the virtual machine
set saveTask = objVM.Save
'Loop waiting for task completion - and display status
while not saveTask.isComplete
WScript.Sleep 1000
wend
'Copy .VMC and .VSV files
MyArray = Split(objVM.File,"\")
Filename = MyArray(Ubound(MyArray))
objFSO.CopyFile objVM.File,DestBackupDir & Filename
MyArray = Split(objVM.SavedStateFilePath,"\")
Filename = MyArray(Ubound(MyArray))
objFSO.CopyFile objVM.SavedStateFilePath,DestBackupDir & Filename
End If
Next
Set objVM = Nothing

' Create Shadow copy of VM drive
oExCmd.WriteLine "vshadow.exe -script=setvar1.cmd -p d:"
oExCmd.WriteLine "call setvar1.cmd"
oExCmd.WriteLine "vshadow.exe -el=%SHADOW_ID_1%,x:"
oExCmd.Close
Result = objShell.run(sExCmd,vbMinimized, TRUE)

' Start VM machine up from saved state
For each objVM in virtualServer.VirtualMachines
'See if vm machine is Saved. If so then resume
If objVM.State = 2 then
'Start virtual machine
objVM.Startup
End If
Next
Set objVM = Nothing
WScript.Sleep 10000


If Result = 0 then
'Loop through all vm machines
For each objVM in virtualServer.VirtualMachines
'See if vm machine is running. If so copy shadow backup of vm disk
drives
If objVM.State = 5 then

'Copy virtual hard disks and undo disks
For each vhd in objVM.HardDiskConnections
MyArray = Split(vhd.undoHardDisk.file,"\")
Filename = MyArray(Ubound(MyArray))
SourceName = "x" &
Right(vhd.undoHardDisk.file,Len(vhd.undoHardDisk.file)-1)
wscript.echo vhd.undoHardDisk.file
wscript.echo SourceName
objFSO.CopyFile SourceName,DestBackupDir & Filename
MyArray = Split(vhd.HardDisk.file,"\")
Filename = MyArray(Ubound(MyArray))
SourceName = "x" &
Right(vhd.HardDisk.file,Len(vhd.HardDisk.file)-1)
objFSO.CopyFile SourceName,DestBackupDir & Filename
Next

End If
Next
End If

' Shutdown all shadow copy instances
if oFileSys.FileExists(sExCmd) then oFileSys.DeleteFile(sExCmd)
set oExCmd = oFileSys.CreateTextFile(sExCmd, CopyOverwrite)
oExCmd.WriteLine "Echo y | vshadow.exe -da"
oExCmd.Close
Result = objShell.run(sExCmd,vbMinimized, TRUE)

'Script ends
wscript.echo "done"
********VBS ends*********************

"Laura E. Hunter [MVP]" wrote:

Are you trying to automate the process of shutting down a guest VM so that
you can back up the entire .VHD as a single file?

Your best bet will be to do so via a script. For example, the following
VBScript code will turn off a Virtual Machine called "Windows 2000 Server":

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

objVM.Turnoff()

You could use these commands to write a script that will turn off the guest
VM, launch your backup software, and then turn the guest VM back on once the
backup is complete.

Try the Virtual Server scripts on TechNet to get you started:
http://www.microsoft.com/technet/scriptcenter/scripts/vs/default.mspx?mfr=true

HTH
--
Laura E. Hunter
Microsoft MVP: Windows Server - Networking
Author: _Active Directory Consultant's Field Guide_
(http://tinyurl.com/7f8ll)
Author: _Active Directory Cookbook, Second Edition_
(http://tinyurl.com/z7svl)

Responses provided as-is; no warranties expressed or implied
"realitychx" <realitychx@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:188E4C6A-E77E-448B-AA89-566892FA9B79@xxxxxxxxxxxxxxxx
anyone know of a way to automate backups of Virtual Servers .vhd ?

thanks in advance



.



Relevant Pages

  • Re: using xml to save/open project data
    ... http://www.TransProCalc.org - Free translation project mgmt software ... set filename tk_getOpenfile ... Exec'ing the script you run it as a separate process, your script won't be able to access its vars. ... generating the xml file is easy enough. ...
    (comp.lang.tcl)
  • Re: MIME - scripting and symbol substitutions
    ... This script is creating a text file with a different filename ... symbol called NEWFILENAME (which works, ... MIME from the command line with all options (so normal DCL ...
    (comp.os.vms)
  • Re: Help me find 5 mistakes and than solution to thoes mistakes!
    ... > 8:# This script will create links to files from all of the filename ... > 10:# arguments provided on stdin if no filenames provided on command ...
    (Fedora)
  • Help with os.spawnv
    ... I've had to migrate back to Python 2.1 and am now trying to use ... This script gets each Ascii file in the workspace, ... for filename in filenames ...
    (comp.lang.python)
  • Re: burning DVD failure
    ... The script showed me 3 devices, ... experiences in the early 90's were on a then-ancient PDP and some Sparcstations, but I've always worked in the Windows world - and for everyday use, I've felt Windows desktop systems are clearly superior since the introduction of XP. ... I installed it as a virtual machine for some testing primarily. ... that much of RAM for this machine. ...
    (microsoft.public.scripting.vbscript)