18.08.2013 Views

Virtual Disk API Programming Guide - Documentation - VMware

Virtual Disk API Programming Guide - Documentation - VMware

Virtual Disk API Programming Guide - Documentation - VMware

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Designing vSphere Backup Solutions<br />

Another flag named memory allows you to include in the snapshot a dump of the powered on virtual machineʹs<br />

in‐memory state. This is not needed for backup, so set this flag to False.<br />

Changed Block Tracking<br />

This feature, first available in vSphere 4, provides the foundation for incremental (or differential) backup of<br />

virtual disks. Your application can back up only changed data as indicated by the QueryChanged<strong>Disk</strong>Areas<br />

method. <strong>Virtual</strong> machines with virtual hardware version 7 and later support changed block tracking. These<br />

virtual machines contain changeTrackingSupported in the capability field of the <strong>Virtual</strong>Machine<br />

managed object. See “Changed Block Tracking on <strong>Virtual</strong> <strong>Disk</strong>s” on page 70 for details.<br />

Extract Backup Data from the Target <strong>Virtual</strong> Machine<br />

Associated with the snapshot you just created are “versions” of the virtual disks. To identify these disks, you<br />

obtain a moRef to the snapshot you just created. From this snapshot moRef, you can extract the disk names and<br />

paths. How to do this is demonstrated in section “Backing Up a <strong>Virtual</strong> <strong>Disk</strong>” on page 69.<br />

To read the data in a virtual disk, it is necessary to use the Vix<strong>Disk</strong>Lib. This library isolates the programmer<br />

from the details of extracting data from a virtual disk and its redo logs. For example, when doing backup you<br />

call functions Vix<strong>Disk</strong>Lib_Open() and Vix<strong>Disk</strong>Lib_Read(), among others. Vix<strong>Disk</strong>Lib allows access to<br />

disk data on sector boundaries only; the transfer size is some multiple of the disk sector size.<br />

When accessing disks on ESXi hosts, Vix<strong>Disk</strong>Lib release 1.0 transferred virtual disk data over the network.<br />

Later Vix<strong>Disk</strong>Lib releases contain <strong>API</strong> enhancements so you can request more efficient data paths, such as<br />

direct SAN access or HotAdding disks to a virtual backup appliance. These efficient data paths requires minor<br />

code changes, such as calling Vix<strong>Disk</strong>Lib_ConnectEx() instead of plain connect.<br />

Part of virtual disk information is metadata: a number of key/value pairs describing configuration of the<br />

virtual disk. Metadata information can be extracted from a virtual disk using the Vix<strong>Disk</strong>Lib functions<br />

Vix<strong>Disk</strong>Lib_GetMetadataKeys() and Vix<strong>Disk</strong>Lib_ReadMetadata(). You should save metadata keys<br />

along with the backup, in case you need to re‐create the virtual disk.<br />

The Vix<strong>Disk</strong>Lib <strong>API</strong> allows a backup application to perform a full backup of a virtual machine. The newer<br />

VixMntapi library can extract information about a guest operating system from its virtual disks, so your<br />

backup application can determine the type of operating system that is involved. This allows mounting the<br />

volumes to device nodes, so your application can perform file‐oriented backups and restores.<br />

Delete the Temporary Snapshot<br />

As the last part of the backup process, you should delete the temporary snapshot. It is no longer needed,<br />

worsens virtual machine performance, and takes up storage space that could be put to better use.<br />

The Restore Process<br />

Your software can follow one of two restore scenarios: either revert to a saved state, or disaster recovery:<br />

To bring an existing virtual machine to a previous state<br />

1 Connect to the server and command it to halt and power off the target virtual machine.<br />

2 Use the server to gain access to the virtual disks. With SAN transport mode, create a snapshot, because<br />

creating and deleting a snapshot is required for SAN mode restore.<br />

3 Transfer the disk images from backup using Vix<strong>Disk</strong>Lib. Revert‐to and delete the snapshot, if applicable.<br />

To completely re-create a virtual machine (disaster recovery)<br />

1 Connect to the server.<br />

2 Command the server to create a new virtual machine and its virtual disks using the configuration<br />

information saved from vim.vm.ConfigInfo during backup.<br />

3 Transfer virtual disk data to the newly created virtual disks using Vix<strong>Disk</strong>Lib. <strong>Virtual</strong> disk data includes<br />

disk formatting information, so you do not need to build any kind of file system on the virtual disks.<br />

<strong>VMware</strong>, Inc. 61

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!