Handling BackupShutdown Events

It is possible for a backup application (requester) to terminate and not generate a BackupComplete event. The backup application could crash, or be terminated (from the Task Manager, for example) and not be able to call IVssBackupComponents::BackupComplete.

Therefore, the VSS infrastructure (rather than the requester) generates a BackupShutdown event whenever an instance of IVssBackupComponents participating in a backup is released, whether it is released by the requester or by the system.

If a backup proceeds properly, a writer will receive a BackupComplete event followed by a BackupShutdown event.

If the operation aborts (the requester generates an Abort event by calling IVssBackupComponents::AbortBackup) or fails abruptly, a writer may receive only a BackupShutdown event, and it may not receive other events that perform cleanup operations. It is up to a writer to determine whether a BackupShutdown event follows a proper sequence of events, or represents an unexpected failure of the backup operations.

The BackupShutdown event handler, CVssWriter::OnBackupShutdown, receives the VSS_ID (GUID) of the shadow copy set of the backup operation being shut down. The writer can use this to determine which backup operation is being shut down, if it has stored the shadow copy set ID during its backup sequence (for example, from within CVssWriter::OnFreeze, CVssWriter::OnThaw, or CVssWriter::OnPostSnapshot) by using CVssWriter::GetCurrentSnapshotSetId.

However, a writer should not call CVssWriter::GetCurrentSnapshotSetId from within CVssWriter::OnBackupShutdown. Also, CVssWriter::GetCurrentSnapshotSetId cannot be called after CVssWriter::OnPostSnapshot returns.

It is possible for the writer to be involved in multiple backup operations, and if a BackupShutdown event is called because of an abrupt shutdown of a requester, the VSS_ID returned could be that of another backup operation the writer was participating in.