Writer Role in VSS Incremental and Differential Backups
A writer's participation in incremental and differential backups typically takes place while handling Identify (CVssWriter::OnIdentify), PrepareForBackup (CVssWriter:OnPrepareBackup), and PostSnapshot (CVssWriter:OnPostSnapshot) events. How a writer participates is shaped by whether it supports backup stamps and last modification times, and whether the requester running the backup supports partial file operations.
Handling Identify Events during Incremental and Differential Backups
While handling the Identify event, writers establish their basic architecture for incremental and differential backup operation through the backup schema (VSS_BACKUP_SCHEMA) and file specification backup type (VSS_FILE_SPEC_BACKUP_TYPE) masks.
A writer indicates which operations it supports in its Writer Metadata Document by creating a bit mask of VSS_BACKUP_SCHEMA values and passing it to the IVssCreateWriterMetadata::SetBackupSchema method. With this, a writer can indicate whether it supports the following:
- Incremental backups (VSS_BS_INCREMENTAL)
- Differential backups (VSS_BS_DIFFERENTIAL)
- Incremental and differential backups cannot be mixed (VSS_BS_EXCLUSIVE_INCREMENTAL_DIFFERENTIAL)
- Incremental and differential backups using backup stamps (VSS_BS_TIMESTAMPED)
- Incremental and differential backups on the basis of information about a file's last modification (VSS_BS_LAST_MODIFY)
Writers use the file specification backup type mask to provide file set level information to requesters on how to include files in an incremental or differential backup.
A writer can set a file set's file specification backup type mask when it adds the file set to a component by creating a bit mask of VSS_FILE_SPEC_BACKUP_TYPE values and passing it to IVssCreateWriterMetadata::AddDatabaseFiles, IVssCreateWriterMetadata::AddDatabaseLogFiles, or IVssCreateWriterMetadata::AddFilesToFileGroup.
There are three "backup required" values of the VSS_FILE_SPEC_BACKUP_TYPE enumeration that affect differential and incremental backups:
- VSS_FSBT_ALL_BACKUP_REQUIRED
- VSS_FSBT_INCREMENTAL_BACKUP_REQUIRED
- VSS_FSBT_DIFFERENTIAL_BACKUP_REQUIRED
There are three "shadow copy required" values:
- VSS_FSBT_ALL_SNAPSHOT_REQUIRED
- VSS_FSBT_INCREMENTAL_SNAPSHOT_REQUIRED
- VSS_FSBT_DIFFERENTIAL_SNAPSHOT_REQUIRED
File sets tagged with a file specification backup type of "shadow copy required" indicate whether a requester needs to copy data from a shadow copy when performing INCREMENTAL, DIFFERENTIAL, or ALL (which includes both incremental and differential operations) backup operations.
The "backup required" flag, applied to INCREMENTAL, DIFFERENTIAL, or ALL backup operations, indicates that the writer expects a copy of the current version of the file set to be available following the restore of any backup operation. Typically, this means that if a file set is tagged with "backup required," all its members will be copied to backup media during an incremental or differential backup, regardless of when their backup or modification last occurred.
By default, file sets are added to components with a file specification backup type of VSS_FSBT_ALL_BACKUP_REQUIRED | VSS_FSBT_ALL_SNAPSHOT_REQUIRED. Therefore, unless a writer developer decides not to use the default (by choosing another file specification backup type, using partial file operations, or using differenced files), the files in most file sets will typically be copied in their entirety to backup media.
At this point, the writer's Writer Metadata Document is fully populated with most of information a requester will need to start a differential or incremental backup. Addition specification of file set or file level information to support the backup will be handled during the PrepareForBackup event.
Handling PrepareForBackup Events during Incremental and Differential Backups
Before the requester proceeds with the actual backup operation, writers can modify the specification of an incremental or differential backup by altering the requester's Backup Components Document through the IVssComponent interface.
Because the writers use the IVssComponent interface, they typically perform these preparations while handling the PrepareForBackup event.
In CVssWriter:OnPrepareBackup, writers can more precisely specify how some files are to be evaluated for backup, specify what mechanisms should be used in backing them up, and possibly set backup stamps.
-
Partial Files
-
If a requester supports them, a writer can choose to have an incremental or differential backup implemented by using partial file operations. (Writers can determine if a requester supports partial file operations by calling CVssWriter::IsPartialFileSupportEnabled.)
Writers use IVssComponent::AddPartialFile to indicate those portions of the selected files to be backed up during the incremental or differential operation. Requesters must respect this specification, and must always back up the specified sections of the files. (See Working with Partial Files for more information on partial file operations.)
Using IVssComponent::AddPartialFile, a writer can add a file to the backup that was not previously added to one of its component sets (by IVssCreateWriterMetadata::AddDatabaseFiles, IVssCreateWriterMetadata::AddDatabaseLogFiles, or IVssCreateWriterMetadata::AddFilesToFileGroup) as a partial file. Any new files added to the backup in this manner must be on a volume that already is being shadow copied for this backup.
If a file is involved with partial file operations, this supersedes any file specification backup type, which is ignored.
-
Differenced Files
-
Writers that support a last modified backup schema (VSS_BS_SCHEMA) can add differenced files to an incremental or differential backup.
In specifying a differenced file, a writer uses IVssComponent::AddDifferencedFileByLastModifyTime and specifies a path, a file name, and a recursive flag—however, these do not have to match a file set included in any component.
In fact, a writer can add a file not previously added to one of its component sets (by IVssCreateWriterMetadata::AddDatabaseFiles, IVssCreateWriterMetadata::AddDatabaseLogFiles, or IVssCreateWriterMetadata::AddFilesToFileGroup) to the backup as a differenced file. Any new files added to the backup in this manner must be on a volume that already is being shadow copied for this backup.
Typically, a writer will also specify a time of last modification when adding a differenced file—based on the writer's own history mechanism. This last modification time, if specified, must always be used by requesters in determining if a file needs to be included in an incremental or differential backup.
A writer may choose not to specify a last modification time when adding a differenced file to an incremental or differential backup set. If this is the case, requesters are free to use their own mechanisms—for instance, logs of previous backups or file system information—to determine whether the differenced file should be included in an incremental or differential backup.
The file specification backup type of any differenced file is ignored.
-
Backup Stamps
-
Writers that support backup stamps (VSS_BS_TIMESTAMP) have their own private format for storing information about when a backup last occurred. This information is generated by the writer during backup.
The backup stamp is stored in the Backup Components Document as a string by the IVssComponent::SetBackupStamp method. The backup stamp applies to all file sets in the component (or component set) corresponding to the instance of the IVssComponent.
If a requester has access to the backup stamp of a previous backup, it will have made it available to the writer by calling IVssBackupComponents::SetPreviousBackupStamp.
A writer then can examine this time stamp using IVssComponent::GetPreviousBackupStamp.
Note that the requester merely stores and returns the string containing the backup stamp. It does not know anything about the string's format or how to use it; only the writer has that information.
A writer may choose to update the current backup stamp using IVssComponent::SetBackupStamp after it has called IVssComponent::GetPreviousBackupStamp, thus recording in its own format the date of the current incremental or differential backup operation.