Exemplo n.º 1
0
        /// <summary>
        /// This stage initializes both the requester (this program) and
        /// any writers on the system in preparation for a backup and sets
        /// up a communcation channel between the two.
        /// </summary>
        void InitializeBackup()
        {
            // Here we are retrieving an OS-dependent object that encapsulates
            // all of the VSS functionality.  The OS indepdence that this single
            // factory method provides is one of AlphaVSS's major strengths!
            IVssFactory vss = VssFactoryProvider.Default.GetVssFactory();

            // Now we create a BackupComponents object to manage the backup.
            // This object will have a one-to-one relationship with its backup
            // and must be cleaned up when the backup finishes (ie. it cannot
            // be reused).
            //
            // Note that this object is a member of our class, as it needs to
            // stick around for the full backup.
            _backup = vss.CreateVssBackupComponents();

            // Now we must initialize the components.  We can either start a
            // fresh backup by passing null here, or we could resume a previous
            // backup operation through an earlier use of the SaveXML method.
            _backup.InitializeForBackup(null);

            // At this point, we're supposed to establish communication with
            // the writers on the system.  It is possible before this step to
            // enable or disable specific writers via the BackupComponents'
            // Enable* and Disable* methods.
            _backup.GatherWriterMetadata();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            IVssFactory vssImplementation = VssFactoryProvider.Default.GetVssFactory();

            using (IVssBackupComponents backup = vssImplementation.CreateVssBackupComponents())
            {
                backup.InitializeForBackup(null);

                backup.SetContext(VssSnapshotContext.All);

                foreach (VssSnapshotProperties prop in backup.QuerySnapshots())
                {
                    Console.WriteLine("Snapshot ID: {0:B}", prop.SnapshotId);
                    Console.WriteLine("Snapshot Set ID: {0:B}", prop.SnapshotSetId);
                    Console.WriteLine("Original Volume Name: {0}", prop.OriginalVolumeName);
                    Console.WriteLine();
                }
            }
        }