Low Level Backup
Procedures
This section describes low level details
that may be helpful in coding a backup application. It is not the intent of
this material to impose a design, but only to serve as a guideline with
examples and exposition. The code samples provided below are not complete. They
generally lack error handling and ignore critical details.
Communicate with the Server Connections to the server machine require credentials: user name, password, and host name (or IP address). The following code connects to the server and extracts information useful for manipulating a service: The PropertyCollector The PropertyCollector is used in this section to apply the above details to the backup task. Creating a Snapshot Before performing a backup operation, you must create a snapshot of the target virtual machine. Both full and incremental backup rely on the snapshot in vSphere.Backing Up a Virtual Disk This section describes how to get data from the Virtual Disk after you have identified it. In order to access a virtual disk, you must use the VixDiskLib . The following code shows how to initialize the VixDiskLib and use it for accessing a virtual disk. All operations require a VixDiskLib connection to access virtual disk data. At the present time VixDiskLib is not implemented for the Java language, so this code is C++ language:Deleting a Snapshot When you are done performing a backup, you need to delete the temporary snapshot. You can get the moRef for the snapshot from taskRef.info.result as describe above for the create snapshot operation. The following Java code demonstrates how to delete the snapshot:New Query Allocated Blocks Function As of vSphere 6.7, developers can call VixDiskLib_QueryAllocatedBlocks to accelerate the backup process, especially with large virtual disks. By knowing which blocks are allocated, an application can avoid reading irrelevant sectors and thus reduce data transfer during backup. Changed Block Tracking on Virtual Disks On ESXi hosts release 4.0 and later, virtual machines can keep track of disk sectors that have changed. This is called changed block tracking. Its method in the VMware vSphere API is QueryChangedDiskAreas , which takes the following parameters: