Re: virtual server backups
- From: realitychx <realitychx@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 23 Jan 2007 08:10:03 -0800
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
- References:
- Re: virtual server backups
- From: Laura E. Hunter [MVP]
- Re: virtual server backups
- Prev by Date: Re: Functional Mode and Remote Access
- Next by Date: Re: File Server Resource Manager (FSRM) will not start
- Previous by thread: Re: virtual server backups
- Next by thread: Re: Functional Mode and Remote Access
- Index(es):
Relevant Pages
|