Aborting VSS Operations
Abort events can be generated during a backup operation in any of the following cases:
- A requester explicitly generates an Abort event by calling IVssBackupComponents::AbortBackup.
- A writer's Freeze and Thaw event handlers (CVssWriter::OnFreeze and CVssWriter::OnThaw) return false, or cannot complete in the time window specified in CVssWriter::Initialize.
- There is any failure of the provider or VSS during the creation of a shadow copy following the PrepareForSnapshot event.
Aborts are not supported for restore operations.
Requester Handling and Creation of Abort Events
An instance of the IVSSBackupComponents interface can be used for only one backup, so if an error occurs in processing a backup it is generally best to release the current instance and start over.
A requester should explicitly signal that it is aborting a backup operation (using IVssBackupComponents::AbortBackup) only after the actual preparation for a backup, involving writers, or the creation of a shadow copy has taken place.
Effectively, this means that any time a requester needs to stop a backup operation after generating a PrepareForBackup event by calling IVssBackupComponents::PrepareForBackup, it should call IVssBackupComponents::AbortBackup and await its return prior to releasing the current IVSSBackupComponents instance.
For example, if a writer vetoed a backup operation, a requester should use IVssBackupComponents::AbortBackup to notify all other writers that the backup operation will not be completed.
Prior to calling PrepareForBackup, or if the call to PrepareForBackup fails, a requester can release the current instance of the IVSSBackupComponents interface without needing to generate an Abort event.
For example, if the current instance of IVSSBackupComponents is being used merely to obtain information by calling IVssBackupComponents::GatherWriterMetadata and generating an Identify event, once information has been returned the instance of IVSSBackupComponents can simply be released.
A requester generates a number of events (PrepareForSnapshot, Freeze, Thaw, and PostSnapshot) when it calls IVssBackupComponents::DoSnapshotSet. While handling the Freeze and Thaw events, a writer may fail and can generate an Abort event on its own. Failure to handle PrepareForSnapshot and PostSnapshot events does not generate an Abort event.
It is not always possible for a requester to know if an Abort event was generated when IVssBackupComponents::DoSnapshotSet indicates failure. Therefore, a requester that needs to terminate a backup operation because the status of IVssBackupComponents::DoSnapshotSet indicates a problem should still call IVssBackupComponents::AbortBackup.
Writer Handling and Creation of Abort Events
As noted previously, a writer can receive an Abort event from a requester, or the provider can trigger one itself. Also, it is possible for a writer to receive multiple Abort events under certain circumstances. Writer developers should code any implementation of CVssWriter::OnAbort with this in mind.
In handling an Abort event, a writer should attempt to restore whatever process it managed to its normal running state, as well as perform any error handling and logging.
This may mean that an implementation of CVssWriter::OnAbort might have to perform many, if not all, of the same tasks as the Thaw event handler (CVssWriter::OnThaw) and the PostSnapshot event handler (CVssWriter::OnPostSnapshot), and these handlers can be called from within CVssWriter::OnAbort.