/// <summary> /// Adds a volume to the current snapshot. /// </summary> /// <param name="VolumeName">Name of the volume to add (eg. "C:\").</param> /// <remarks> /// Note the IsVolumeSupported check prior to adding each volume. /// </remarks> protected void AddVolume(string VolumeName) { if (BackupComponents.IsVolumeSupported(VolumeName)) { SnapId = BackupComponents.AddToSnapshotSet(VolumeName); } else { throw new VssVolumeNotSupportedException(VolumeName); } }
public VolumeShadowCopy(string VolumeName) { IVssImplementation vss = VssUtils.LoadImplementation(); BackupComponents = vss.CreateVssBackupComponents(); BackupComponents.InitializeForBackup(null); BackupComponents.GatherWriterMetadata(); BackupComponents.FreeWriterMetadata(); SetId = BackupComponents.StartSnapshotSet(); AddVolume(Path.GetPathRoot(VolumeName)); BackupComponents.SetBackupState(false, true, VssBackupType.Full, false); BackupComponents.PrepareForBackup(); }
public void Dispose() { try { BackupComponents.BackupComplete(); } catch { } try { BackupComponents.DeleteSnapshotSet(SetId, false); } catch { } try { BackupComponents.Dispose(); } catch { } }
public void DoSnapshot() { BackupComponents.DoSnapshotSet(); }