A typical backup application follows this algorithm:

  • Preferably through vCenter Server, contact the ESXi host and discover the target virtual machine.
  • Ask the ESXi host to take a snapshot of the target virtual machine.
  • Using the vSphere API (PropertyCollector), capture configuration (VirtualMachineConfigInfo) and changed block information (with queryChangedDiskAreas). Save these for later.
  • Using advanced transport functions and VixDiskLib, access the snapshot and save the data in it.
If Changed Block Tracking is enabled, the snapshot contains only incremental backup data.
  • Ask the ESXi host to delete the backup snapshot.

A typical back-in-time disaster recovery or file-based restore follows this algorithm:

  • Preferably through VMware vCenter, contact the ESXi host containing the target virtual machine.
  • Ask the ESXi host to halt and power off the target virtual machine.
  • Using advanced transport functions, restore a snapshot from saved backup data.
  • For disaster recovery to a previous point in time, have the virtual machine revert to the restored snapshot. For file-based restore, mount the snapshot and restore requested files.

Backing Up Virtual Disks in vSphere presents these algorithms in more detail and includes code samples. For best practices in backup and restore, see Tips and Best Practices.