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:
- Keep a record of the virtual machine configuration,VirtualMachineConfigInfo.
- Create a snapshot of the virtual machine, naming itsnapshot_T1.
- Obtain the change ID for each virtual disk in the snapshot,changeId_T1(per VMDK).
- Back up the sectors returned byVixDiskLib_QueryAllocatedBlocks, avoiding unallocated disk.
- Deletesnapshot_T1, keeping a record ofchangeId_T1along with lots of backed-up data.
For the incremental backup at time T2:
- Create a snapshot of the virtual machine, naming itsnapshot_T2.
- Obtain the change ID for each virtual disk in the snapshot,changeId_T2(per VMDK).
- Back up the sectors returned byqueryChangedDiskAreas(snapshot_T2,...changeId_T1).
- Deletesnapshot_T2, keeping a record ofchangeId_T2along with backed-up data.
For the incremental backup at time T3:
- Create a snapshot of the virtual machine, naming itsnapshot_T3.At time T3 you can no longer obtain a list of changes between T1 and T2.
- Obtain the change ID for each virtual disk in the snapshot,changeId_T3(per VMDK).
- Back up the sectors returned byqueryChangedDiskAreas(snapshot_T3,...changeId_T2).A differential backup could be done withqueryChangedDiskAreas(snapshot_T3,...changeId_T1).
- Deletesnapshot_T3, keeping a record ofchangeId_T3along with backed-up data.
For a disaster recovery at time T4:
- Create a new virtual machine with no guest operating system installed, using configuration parameters you previously saved fromVirtualMachineConfigInfo. You do not need to format the virtual disks, because restored data includes formatting information.
- Restore data from the backup at time T3. Keep track of which disk sectors you restore.
- Restore data from the incremental backup at time T2, skipping any sectors already recovered.With differential backup, you can skip copying the T2 backup.
- 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.
- 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.