コード例 #1
0
        internal void PrepareAll()
        {
            // lauch pre-backup commands/scripts
            string [] cmdOuts = ExecuteCommand(this.BackupSet.Preop);
            HubNotificationEvent(this.Id, 710, "STDOUT", cmdOuts[0]);
            HubNotificationEvent(this.Id, 710, "STDERR", cmdOuts[1]);

            // DEBUG print basepaths
            foreach (BasePath bsp in this.BackupSet.BasePaths)
            {
                Console.WriteLine("0##### bp path=" + bsp.Path + ", type=" + bsp.Type);
            }



            // Gather the FSs paths required by special objects (if there are any)
            //Dictionary<string, SPOMetadata> spoMetadatas = PrepareSpecialObjects();
            List <Tuple <string, SPOMetadata, List <string> > > spoMetadatas = PrepareSpecialObjects();

            // Telling Special objects to tell the app they manage to put themselves into backup mode (if possble)
            // and/or freeze their IOs
            Logger.Append(Severity.INFO, "Freezing " + this.specialObjects.Count + " special objects...");
            foreach (ISpecialObject spo in this.specialObjects)
            {
                spo.Freeze();
            }


            SanitizePaths();


            // Now snapshot (if requested).
            PrepareDrivesAndSnapshots();


            this.Index   = new Index(this.Id, (this.Level != BackupLevel.Full));
            Index.Header = new IndexHeader {
                TaskId = this.Id, BackupType = this.Level
            };
            //Index.Header.RootDrives = backupRootDrives;
            Index.Create(backupRootDrives);            //taskId, (this.Bs.ScheduleTimes[0].Level != BackupLevel.Full), this.RootDrives);
            Index.WriteHeaders();

            // Collect incremental providers metadata (for subsequent backups)
            foreach (BackupRootDrive brd in backupRootDrives)
            {
                Dictionary <string, byte[]> provMetadata = IncrementalPluginProvider.SignalBackupBegin(this.Id, brd);
                if (provMetadata == null)
                {
                    continue;
                }
                foreach (KeyValuePair <string, byte[]> kp in provMetadata)
                {
                    Logger.Append(Severity.TRIVIA, "Signaled backup to Incremental providers, got metadata from " + kp.Key);
                    Index.AddProviderMetadata(kp.Key, brd, kp.Value);
                }
            }
            if (spoMetadatas != null)
            {
                //foreach(KeyValuePair<string,SPOMetadata> spoMetadata in spoMetadatas){
                foreach (Tuple <string, SPOMetadata, List <string> > tuple in spoMetadatas)
                {
                    if (tuple.Item2 != null)
                    {
                        using (MemoryStream mStr = new MemoryStream()){
                            (new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()).Serialize(mStr, tuple.Item2);
                            Index.AddProviderMetadata(tuple.Item1, backupRootDrives[0], mStr.GetBuffer());
                            Index.AddSpecialObject(tuple.Item1, tuple.Item3);
                        }
                    }
                    else
                    {
                        Logger.Append(Severity.WARNING, "Could'nt save metadata from provider '" + tuple.Item1 + "' : metadata is null");
                    }
                }
            }
        }