maandag, december 11, 2006

VMware: VCB, TSM & VM groups

I am currently working on a VCB implementation for a very large customer (together with Geert Baeke). The customer uses TSM (Tivoli Storage Manager) to backup full .vmdk files.

TSM uses a pre-command to snapshot a list of VMs. However, this is a string in a small textbox. It works in the following format: pre-command <jobname> <VM1.FQDN> <VM2.FQDN> <...>. Needless to say this is very difficult to maintain and is error-prone. That's why I wrote a vbscript to replace the default pre-command.bat file and use a text file as VM list.

---------------------------------------------------------------Option Explicit
On Error Resume Next

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Dim strVCBFile, strVCBList, strPreCmd, strJobName, objFSO, objShell, objFile, objStream, strStream

strVCBFile = "VCBList.txt"
strPreCmd = "pre-command.bat"
strJobName = "VMFullJob"
strVCBList = ""

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")

If objFSO.FileExists(strVCBFile) Then
Set objFile = objFSO.GetFile(strVCBFile)
Set objStream = objFile.OpenAsTextStream(ForReading, TristateUseDefault)
Do While Not objStream.AtEndOfStream
strStream = objStream.readline
strStream = Trim(strStream)
strVCBList = strVCBList & " " & strStream
Wscript.echo strVCBList
Loop
'run the backup command
objShell.Run strPreCmd &amp; " " & strJobName & strVCBList
Else
'do nothing
End If

'cleanup
Set objFile = nothing
Set objStream = nothing
Set objFSO = nothing

---------------------------------------------------------------

Additional steps to perform:

  • Create a pre-command.vbs with the above content
  • Create a VCBList.txt file that looks like this (use enter to seperate):
  • VM1.contoso.com-FullVM
    VM2.contoso.com-FullVM

  • Copy the pre-command.vbs & VCBList.txt in the folder where pre-command.bat is located (for TSM this is C:\Program Files\Tivoli\TSM\baclient)
  • Edit the scheduler to add the pre-command.vbs in the preschedule command window (via Edit -> Preferences and the scheduler TAB)
  • Do NOT forget to also set the post-command WITH THE SAME JOBNAME
  • Test :)

3 opmerkingen:

VogelBird zei

This is great! We've developed a similar process with a bit of extra logic to distribute backups by weekend (because that's when our vcb backups run). They are split into 3 weekends, 1st-2nd-3rd weekend of the month. Scripts are an admins best friend.

This is really leading to the question question...what is the process you use to recover you VM's once you've backed them up? Now we all have these large vmbk file and need to get them back to the ESX server to re-import the machine. Any tips or tricks there?

Vincent Vlieghe zei

Hi Anthony,

We are looking into VizionCore ESXRanger (VCB integrated) now, because we had similar "problems" when restoring vmdks... To slow...

Ben zei

This script is a great idea. I'm using something similar to manage VCB backups. I believe the first line of the script should be 'option explicit' though.

Good work!