Wednesday, August 27, 2008

File Level Recovery from within a VMDK backup

One of the frequently asked question when implementing VMware on NFS is how would you implement file recovery from within a VMDK backup and what tools are available to accomplish this?

Implementing array based snapshots to backup entire datastores and their contents is a simple and a well documented process, however, often times customers have the need to recover specific files from within VMDKs.

Depending on the Datastore type used (VMFS vs NFS) the process and the administrative steps required as well as the associated costs vary greatly.

With VMFS you can could treat the Virtual Machines as Physical servers and deploy backup agents inside each VM and have file level backup and restore granularity. All that at the expense of typically higher CPU and Memory consumption, multiple backup schedules and in general higher acquisition and operational costs.

Another approach would be to use a combination of Vmware’s Consolidated Backup (VCB) and Backup software and do file level backups and restores.

How about NFS?

The backup process using NFS is very simple. Because we control the filesystem we know what’s in there and we can recover specific files (.vmdk, .vmx) or any file that’s in a VM directory.

However, what is the process to provide further granularity and be able to restore a specific file from within a VMDK backup in an NFS implementation without using backup software agents or proxies?

There are several options to accomplish this however, today I’ll talk about a couple of them. Both require a CIFS share to be created onto the snapshot directory of the NFS volume (i.e /vol/vmdata/.snapshot).

In both cases you will be accessing the snapshot directory from the Virtual Machine that requires the needed file by specifying the UNC path. This process works for Windows VMs and requires VMDKs with a single partition.

Option 1

This option was recently discovered and further developed (Registry entries and Batch script) by one of the NetApp SE’s (Mike Arndt) and it’s very effective and free for those customers that already have a CIFS license with their NetApp arrays, which is a very large percentage. The other important factor is that Mike has made it a point-and-click process. Great job Mike!!!

As part of their VMware Disk Developer’s Kit, VMware provides a vmware-mount.exe utility that allows for mounting an existing VMDK on a Windows Driver letter. We’ll be using this utility as well to mount the VMDK as well as some Registry Entries and a Batch Script to further simplify the file recovery process.

Step 1: Download and install the kit from the above link

Step 2: Registry Entries

The following registry entries can be added by putting them in a file with a .reg extension and double-clicking on the file. The entries will provide you with a “VMDK Mount” and “VMDK UnMount” option when you right click in the Windows Explorer interface.

; The following registry keys will put right click shortcuts
in place for VMDKMounter.






@="VMDK Mount"


@="cmd.exe /c "c:\\Program Files\\NetApp\\VMDKMounter\\vmdkmounter.bat" mount %1"


@="VMDK UnMount"


@="cmd.exe /c "c:\\Program Files\\NetApp\\VMDKMounter\\vmdkmounter.bat" unmount %1"

Step 3: Batch Script

The following batch script needs to be placed in C:\Program Files\NetApp\VMDKMounter in order for the previously mentioned registry entries to work properly.

Note: The Lines marked in red should be one line.

SET vmware_mount_cmd_path="C:\\Program Files\\VMware\\
VMware Virtual Disk Development Kit\\bin\\vmware-mount.exe"
IF EXIST %vmware_mount_cmd_path% GOTO CONTINUE
ECHO The vmware-mount utility is not installed. Exiting.
IF "%1"=="mount" GOTO GETDRIVE
set drive_letter=%2
ECHO Unmounting VMDK on drive %2 ...
%vmware_mount_cmd_path% %drive_letter:~0,2% /d /f

SET /P drive_letter="Enter Drive Letter [Z:] "
IF NOT "%drive_letter%"=="" GOTO CHECKDRIVE
SET drive_letter=Z:

ECHO Drive %drive_letter% appears to already be in use! Exiting.

ECHO Mounting VMDK on drive %2 ...
%vmware_mount_cmd_path% %drive_letter% %2 /m:n
explorer %drive_letter%

@ping -n 5 -w 1000 > nul

File Recovery Process
Step 1: Use the UNC path to access the snapshot directory (Figure 1)
Step 2: Pick the snapshot you want and drill down and into the VM folder
Step 3: Select the *.vmdk (not the -flat.vmdk), right click the "VMDK Mount"
Step 3: Drag and Drop the file and use"VMDK UnMount" option when done.

No comments: