Updating Applications for Advanced Transport
Updating Applications for Advanced Transport
To update your applications for advanced transport with managed disk, follow these steps:
1 Find all instances of VixDiskLib_Connect() and change them to VixDiskLib_ConnectEx().The vixDiskLib sample program was extended to use VixDiskLib_ConnectEx() with the -mod option.
2 Likewise, change VixDiskLib_Init() to VixDiskLib_InitEx() and be sure to call it only once.
3 Disable virtual machine relocation with the VixDiskLib_PrepareForAccess() call.
4 Add parameters in the middle:
a TRUE for high performance read-only access, FALSE for read/write access.
b Snapshot moRef, if applicable.
c NULL to accept transport method defaults (recommended).
5 Re-enable virtual machine relocation with the VixDiskLib_EndAccess() call.
6 Find VixDiskLib_Disconnect() near the end of program, and for safety add a VixDiskLib_Cleanup() call immediately afterwards.
7 Compile with the new flexible-transport-enabled version of VixDiskLib.The advanced transport functions are useful for backing up or restoring data on virtual disks managed by VMware vSphere. Backup is based on the snapshot mechanism, which provides a data view at a certain point in time, and allows access to quiescent data on the parent disk while the child disk continues changing.Algorithm for vSphere Backup
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.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. If you specify change ID as * (star), queryChangedDiskAreas returns a list of allocated disk sectors so your backup can skip the unallocated sectors of sparse virtual disk.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 queryChangedDiskAreas(..."*"), 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.
Help us improve this information. Send feedback to [email protected].