Backup and Recovery Example

The VMware vSphere API method
queryChangedDiskArea
returns a list of disk sectors that changed between an existing snapshot, and some previous time identified by a change ID.
The
queryChangedDiskAreas
method takes four arguments, including a snapshot reference and a change ID. It returns a list of disk sectors that changed between the time indicated by the change ID and the time of the snapshot. This is useful for incremental backup. Before a full backup, you can call
VixDiskLib_QueryAllocatedBlocks
to get a list of in-use disk sectors so your backup can skip unallocated sectors.
Suppose that you create an initial backup at time
T1
. Later at time
T2
you take an incremental backup, and another incremental backup at time
T3
. (You could use differential backups instead of incremental backups, which would trade off greater backup time and bandwidth for shorter restore time.)
For the full backup at time T1:
  1. Keep a record of the virtual machine configuration,
    VirtualMachineConfigInfo
    .
  2. Create a snapshot of the virtual machine, naming it
    snapshot_T1
    .
  3. Obtain the change ID for each virtual disk in the snapshot,
    changeId_T1
    (per VMDK).
  4. Back up the sectors returned by
    VixDiskLib_QueryAllocatedBlocks
    , avoiding unallocated disk.
  5. Delete
    snapshot_T1
    , keeping a record of
    changeId_T1
    along with lots of backed-up data.
For the incremental backup at time T2:
  1. Create a snapshot of the virtual machine, naming it
    snapshot_T2
    .
  2. Obtain the change ID for each virtual disk in the snapshot,
    changeId_T2
    (per VMDK).
  3. Back up the sectors returned by
    queryChangedDiskAreas(snapshot_T2
    ,...
    changeId_T1)
    .
  4. Delete
    snapshot_T2
    , keeping a record of
    changeId_T2
    along with backed-up data.
For the incremental backup at time T3:
  1. Create a snapshot of the virtual machine, naming it
    snapshot_T3
    .
    At time T3 you can no longer obtain a list of changes between T1 and T2.
  2. Obtain the change ID for each virtual disk in the snapshot,
    changeId_T3
    (per VMDK).
  3. Back up the sectors returned by
    queryChangedDiskAreas(snapshot_T3
    ,...
    changeId_T2)
    .
    A differential backup could be done with
    queryChangedDiskAreas(snapshot_T3
    ,...
    changeId_T1)
    .
  4. Delete
    snapshot_T3
    , keeping a record of
    changeId_T3
    along with backed-up data.
For a disaster recovery at time T4:
  1. Create a new virtual machine with no guest operating system installed, using configuration parameters you previously saved from
    VirtualMachineConfigInfo
    . You do not need to format the virtual disks, because restored data includes formatting information.
  2. Restore data from the backup at time T3. Keep track of which disk sectors you restore.
  3. Restore data from the incremental backup at time T2, skipping any sectors already recovered.
    With differential backup, you can skip copying the T2 backup.
  4. Restore data from the full backup at time T1, skipping any sectors already recovered. The reason for working backwards is to get the newest data while avoiding unnecessary data copying.
  5. Power on the recovered virtual machine.
When programs open remote disk with SAN transport mode, they can write to the base disk, but they cannot write to a snapshot (redo log). Opening and writing snapshots is supported only for hosted disk.