When you want to use SftpDrive in combination with your standard back-up software you have to find some way to unlock the flat.vmdk file. Well there is a way and it’s staring you right in the face. The only problem is it isn’t well documented, so it will cost some extra time to figure out how it works. The basis for the unlocking mechanism is the following list of files:
09-03-2007 10:22 827.392 libeay32.dll
09-03-2007 10:22 159.744 ssleay32.dll
09-03-2007 10:29 8.785.920 types.dll
09-03-2007 10:29 1.171.456 vcbSnapshot.exe
09-03-2007 10:29 1.183.744 vcbVmName.exe
09-03-2007 10:29 1.626.112 vmacore.dll
09-03-2007 10:29 1.097.728 vmomi.dll
These files are part of the VCB download from VMware. First we must get the ManagedObjectReference of the VirtualMachine, it’s an ID you can retrieve with the vcbVmName.exe command. This command has the following options:
VMware Consolidated Backup -- VM Locator Utility, Version 1.0.2 (42090)
(C) 2005,2006, VMware, Inc. All rights reserved.
Usage:
vcbVmName -h <url> -u <username> -p <password>
-s <searchSpec> [-c <cachefile>] [<verbosity>]
<url> := <hostname>[":"<port>]
<username> := <string>
<password> := <string>
<searchSpec> := <Type>":"<Qualifier>
<Type> := "Any"|"IpAddr"|"MoRef"|"Uuid"|"Powerstate"|
"Name"
<Qualifier> := <string>
<cachefile> := <filename>
<verbosity> := -L (0-6)
Example:
Use the following command line to locate a VM with the host name
"buvm01.eng.vmware.com" on the ESX server "esx17.vmware.com"
using the user name "sdk" and the password "foobar":
vcbVmName -h esx17.vmware.com -u sdk -p foobar -s ipaddr:buvm01.eng.vmware.com
In this example I’ll use the power state option and retrieve a list of all the VM’s that are powered on.
D:\VCB>vcbvmname.exe -h vcserver -u vcuser -p vcpassword -s Powerstate:on
[2007-07-09 20:38:49.398 'App' 4856 info] Current working directory: D:\VCB
[2007-07-09 20:38:51.004 'BaseLibs' 5444 warning] [Vmdb_Unset] Unsetting unknown path: /vmomi/
Found VM:
moref:vm-41
name:nl-nwg-a16 Test
uuid:5012265c-5cfb-9c5e-58ce-0805ece33063
ipaddr:192.50.22.112
Found VM:
moref:vm-561
name:nl-nwg-a21 Prod
uuid:501287ec-b4b2-5cb0-5750-b6031619aa37
ipaddr:192.50.22.126
The next step is the creation of the snapshot. You can use the vcbSnapshot.exe tool that has the following options.
VMware Consolidated Backup -- Snapshot Utility, Version 1.0.2 (42090)
(C) 2005,2006, VMware, Inc. All rights reserved.
Usage:
vcbSnapshot -h <url> -u <username> -p <password> [<verbosity>] <command>
<url> := <hostname>[":"<port>]
<command> := <create>|<find>|<list>|<delete>
<verbosity> := -L (0-6)
<create> := -c <VmId> <SnapshotName> [<Description>]
<find> := -f <VmId> <SnapshotName>
<list> := -l <VmId> <SsId>
<delete> := -d <VmId> <SsId>
<VmId> := "moref:"<Sdk-MoRef>
<SsId> := "ssid:"<Sdk-MoRef>
You can use the information from the vcbVmName.exe command to construct the vcbSnapshot.exe command.
D:\VCB>vcbSnapshot.exe -h vcserver -u vcuser -p vcpassword -c moref:vm-561 "test"
[2007-07-09 20:48:15.990 'App' 5892 info] Current working directory: D:\VCB
[2007-07-09 20:48:17.596 'BaseLibs' 5388 warning] [Vmdb_Unset] Unsetting unknown path: /vmomi/
[2007-07-09 20:48:22.776 'CreateSnapshot' 5892 info] Creating snapshot
SsId:snapshot-841
Now you can start to back-up your flat.vmdk because there’s no lock on it anymore and all the changes are written in the delta file. This will cost some performance caused by SCSI locking, therefore the best time to do this is outside business hours. When you are done, don’t forget to delete the snapshot. What you have to take is the SsId from when you created the snapshot and use it in the following command.
D:\VCB>vcbSnapshot.exe -h vcserver -u vcuser -p vcpassword -d moref:vm-561 ssid:snapshot-841
[2007-07-09 21:11:21.192 'App' 4984 info] Current working directory: D:\VCB
[2007-07-09 21:11:22.798 'BaseLibs' 4784 warning] [Vmdb_Unset] Unsetting unknown path: /vmomi/
The changes in the delta file are committed to the flat.vmdk and the snapshot is gone.