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
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
6
Find VixDiskLib_Disconnect() near the end of program, and for safety add a VixDiskLib_Cleanup() call immediately afterwards.
7
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:
Using the vSphere API (PropertyCollector), capture configuration (VirtualMachineConfigInfo) and changed block information (with queryChangedDiskAreas). Save these for later.
A typical back-in-time disaster recovery or file-based restore follows this algorithm:
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
2
3
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
2
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
At time T3 you can no longer obtain a list of changes between T1 and T2.
2
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
3
With differential backup, you can skip copying the T2 backup.
4
5
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.