Esempio n. 1
0
File: Hub.cs Progetto: radtek/BackO
        /// <summary>
        /// Calculates the chunk destination(s) upon receiving client node request for storage space.
        /// The algorithm is the following
        /// -take all online storage nodes
        /// -restrict to those eligible from task conf (members of required storagegroup(s)
        /// -restrict to those having enough space to store (task chunk's max size)*task budget
        /// -order by reverse  current load (the less loaded node(s) will be elected)
        /// - if needed, restrict to those not present in exclusion list (unreachable nodes)
        /// <b>Note: </b> Several requests to this method may be made before nodes CurrentLoad is updated (when real transfer session starts),
        /// which means we might endup selecting some nodes too many times.
        /// This is an expected behavior, since CurrentLoad has to be considered more as a hint than as an
        /// absolute, always-right, basis for storage destinations calculation.
        /// </summary>
        /// <returns>
        /// The chunk destinations.
        /// </returns>
        /// <param name='taskId'>
        /// Task identifier.
        /// </param>
        /// <param name='parallelism'>
        /// Parallelism.
        /// </param>
        /// <param name='budget'>
        /// Budget.
        /// </param>
        /// <param name='nodesToExclude'>
        /// Nodes to exclude (because signaled as unreachable by client node).
        /// </param>
        private List <PeerNode> CalculateChunkDestinations(long taskId, int parallelism, int budget, List <P2PBackup.Common.Node> nodesToExclude)
        {
            List <PeerNode> destinations = new List <PeerNode>();
            // budget for each storage node will be budget/parallelism
            int       perNodeBudget = (budget / parallelism) + 1;
            BackupSet bs            = TaskScheduler.Instance().GetTask(taskId).BackupSet;

            // All the magic to select a storage node happends here. How cool Linq is!
            // Query itself should be self-explainatory
            var destinationRawList = (from PeerNode node in NodesList
                                      where  node.StorageGroup == bs.StorageGroup && node.StoragePriority > 0 &&
                                      (node.StorageSize - node.StorageUsed - node.ReservedSpace) > bs.MaxChunkSize * perNodeBudget &&
                                      !nodesToExclude.Contains(node)
                                      orderby node.CurrentLoad descending
                                      select node).Take(parallelism).ToList <PeerNode>();

            if (destinationRawList.Count == 0)
            {
                Logger.Append("HUBRN", Severity.ERROR, "Could not choose any storage node from group " + bs.StorageGroup + " for task #" + taskId + " with parallelism=" + parallelism + " and budget=" + budget + " (" + budget * bs.MaxChunkSize / 1024 / 1024 + "MB required)");
            }
            //if we can't find enough storage nodes, we will use fewer nodes but require more storage space from each one
            if (0 < destinationRawList.Count && destinationRawList.Count < parallelism)
            {
                Logger.Append("HUBRN", Severity.WARNING, "Not enough storage nodes to satisfy parallelism (" + parallelism + ") of task #" + taskId);
                CalculateChunkDestinations(taskId, destinationRawList.Count, budget, null);
            }
            for (int i = 0; i < Math.Min(parallelism, destinationRawList.Count); i++)
            {
                //destinationRawList[i].ReservedSpace += bs.MaxChunkSize*perNodeBudget;
                destinations.Add(destinationRawList[i]);
            }
            return(destinations);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the last backup taken
        /// </summary>
        /// <returns></returns>
        public string GetLastBackupTaken()
        {
            string    lastBackup            = string.Empty;
            int       lastSelectedIndex     = GetLastSelectedBackupSetIndex();
            BackupSet lastSelectedBackupSet = lastSelectedIndex >= 0 && this.RestorePlan.RestoreOperations != null && this.RestorePlan.RestoreOperations.Count > 0 ?
                                              this.RestorePlan.RestoreOperations[lastSelectedIndex].BackupSet : null;

            if (this.RestorePlanner.RestoreToLastBackup &&
                lastSelectedBackupSet != null &&
                this.RestorePlan.RestoreOperations.Count > 0 &&
                lastSelectedBackupSet != null)
            {
                bool     isTheLastOneSelected = lastSelectedIndex == this.RestorePlan.RestoreOperations.Count - 1;
                DateTime backupTime           = lastSelectedBackupSet.BackupStartDate;
                string   backupTimeStr        = backupTime.ToLongDateString() + " " + backupTime.ToLongTimeString();
                lastBackup = isTheLastOneSelected ?
                             string.Format(CultureInfo.CurrentCulture, SR.TheLastBackupTaken, (backupTimeStr)) : backupTimeStr;
            }
            else if (GetFirstSelectedBackupSetIndex() == 0 && !this.RestorePlanner.RestoreToLastBackup)
            {
                lastBackup = this.CurrentRestorePointInTime.Value.ToLongDateString() +
                             " " + this.CurrentRestorePointInTime.Value.ToLongTimeString();
            }
            return(lastBackup);
        }
        public BackupSetViewModel(BackupSet backupSet)//, IUIVisualizerService uiVisualizerService)
        {
           // Argument.IsNotNull(() => backupSet);
            //Argument.IsNotNull(() => uiVisualizerService);
            BackupSet = backupSet;
           // _uiVisualizerService = uiVisualizerService;

            BrowseSourceCommand = new Command(() => SourceDirectory = SetDirectory(SourceDirectory, "Select Source Directory"));
            BrowseDestinationCommand = new Command(() => DestinationDirectory = SetDirectory(DestinationDirectory, "Select Destination Directory"));
            ExcludeDirectoriesCommand = new Command(OnExcludeDirectoriesExecute, ()=>!String.IsNullOrEmpty(SourceDirectory));
            RunBackupCommand = new Command(() => 
                {
                    if(BackupSet.DestinationType == BackupDestinationType.ExternalDrive)
                    {
                        var typeFactory = this.GetTypeFactory();
                        //var driveSelectionViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion<DriveSelectionViewModel>();
                       // if(_uiVisualizerService.ShowDialog(driveSelectionViewModel) == true )
                       // {
                       //     UpdateDestinationDriveLetter(driveSelectionViewModel.SelectedDrive.Name);
                       // }
                        
                    }
                    BackupSet.RunBackup();
                }  
                , () =>   ProcessingStatus == BackupProcessingStatus.NotStarted ||
                                                                                ProcessingStatus == BackupProcessingStatus.Cancelled ||
                                                                                ProcessingStatus == BackupProcessingStatus.Finished);
            CancelBackupCommand = new Command(() => BackupSet.CancelBackup(), ()=>  ProcessingStatus != BackupProcessingStatus.NotStarted &&
                                                                                    ProcessingStatus != BackupProcessingStatus.Cancelled &&
                                                                                    ProcessingStatus != BackupProcessingStatus.Finished);

            
        }        
        public BackupSetViewModel(BackupSet backupSet)//, IUIVisualizerService uiVisualizerService)
        {
            // Argument.IsNotNull(() => backupSet);
            //Argument.IsNotNull(() => uiVisualizerService);
            BackupSet = backupSet;
            // _uiVisualizerService = uiVisualizerService;

            BrowseSourceCommand       = new Command(() => SourceDirectory = SetDirectory(SourceDirectory, "Select Source Directory"));
            BrowseDestinationCommand  = new Command(() => DestinationDirectory = SetDirectory(DestinationDirectory, "Select Destination Directory"));
            ExcludeDirectoriesCommand = new Command(OnExcludeDirectoriesExecute, () => !String.IsNullOrEmpty(SourceDirectory));
            RunBackupCommand          = new Command(() =>
            {
                if (BackupSet.DestinationType == BackupDestinationType.ExternalDrive)
                {
                    var typeFactory = this.GetTypeFactory();
                    //var driveSelectionViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion<DriveSelectionViewModel>();
                    // if(_uiVisualizerService.ShowDialog(driveSelectionViewModel) == true )
                    // {
                    //     UpdateDestinationDriveLetter(driveSelectionViewModel.SelectedDrive.Name);
                    // }
                }
                BackupSet.RunBackup();
            }
                                                    , () => ProcessingStatus == BackupProcessingStatus.NotStarted ||
                                                    ProcessingStatus == BackupProcessingStatus.Cancelled ||
                                                    ProcessingStatus == BackupProcessingStatus.Finished);
            CancelBackupCommand = new Command(() => BackupSet.CancelBackup(), () => ProcessingStatus != BackupProcessingStatus.NotStarted &&
                                              ProcessingStatus != BackupProcessingStatus.Cancelled &&
                                              ProcessingStatus != BackupProcessingStatus.Finished);
        }
Esempio n. 5
0
        /// <summary>
        /// Update the specified BackupSet, and its ScheduleTimes.
        /// TEchnically, there is no such thing as 'update' for BackupSet object, since we need to keep it without modifications
        /// for past backup tasks to be restorable. So instead of updating, we insert a brand new object with an incremented 'Generation'
        /// </summary>
        /// <param name='bs'>
        /// Bs.
        /// </param>
        public BackupSet Update(BackupSet bs)
        {
            // for security reasons, don't trust generation received from the wild
            bs.Generation = GetById(bs.Id).Generation;
            using (dbc = DAL.Instance.GetDb()){
                dbc.Open();
                IDbTransaction dbt = dbc.BeginTransaction();
                try{
                    bs.Generation++;
                    dbc.Update <BackupSet>(new { Enabled = false }, p => p.Id == bs.Id && p.Enabled);
                    new ScheduleDAO().Delete(bs.Id);
                    dbc.Insert(bs);

                    foreach (ScheduleTime st in bs.ScheduleTimes)
                    {
                        st.BackupSetId = bs.Id;
                    }
                    new ScheduleDAO().Save(bs.ScheduleTimes);
                    dbt.Commit();
                }
                catch (Exception e) {               // we want to log what happens since it's more than a simple SQL query
                    Utilities.Logger.Append("DAO", Severity.ERROR, "Could not update BackupSet #" + bs.Id + " : " + e.ToString());
                    dbt.Rollback();
                    throw(e);
                }
            }
            return(bs);
        }
Esempio n. 6
0
            private void DisplayRestore()
            {
                InitStyles();

                String[] games = SAVE.manager.GetBackupSetNameArray();

                GUILayout.BeginVertical();
                DrawTitle("Restore game");
                restoreListscrollPosition = GUILayout.BeginScrollView(restoreListscrollPosition, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.box, GUILayout.Height(155));
                selectedGameToRestore     = GUILayout.SelectionGrid(selectedGameToRestore, games, 1, GUILayout.Width(SELECTION_GRID_WIDTH));
                String game = games[selectedGameToRestore];

                GUILayout.EndScrollView();
                BackupSet backupSet = SAVE.manager.GetBackupSetForName(games[selectedGameToRestore]);

                String[] backups = backupSet.GetBackupsAsArray();
                GUILayout.Label("From backup", HighLogic.Skin.label);
                backupListscrollPosition = GUILayout.BeginScrollView(backupListscrollPosition, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.box, GUILayout.Height(205));
                selectedBackupToRestore  = GUILayout.SelectionGrid(selectedBackupToRestore, backups, 1, GUILayout.Width(SELECTION_GRID_WIDTH));
                String backup = backups.Length > 0?backups[selectedBackupToRestore]:"";

                GUILayout.EndScrollView();
                SAVE.configuration.backupBeforeRestore = GUILayout.Toggle(SAVE.configuration.backupBeforeRestore, " Create a backup before restore");
                SAVE.configuration.disabled            = GUILayout.Toggle(SAVE.configuration.disabled, " Temporary disable backups until restart");
                GUILayout.BeginHorizontal();
                GUI.enabled   = backups.Length > 0;
                deleteEnabled = GUILayout.Toggle(deleteEnabled, "");
                GUI.enabled   = backups.Length > 0 && deleteEnabled;
                if (GUILayout.Button("Delete", STYLE_DELETE_BUTTON))
                {
                    SAVE.manager.DeleteBackup(backupSet, backup);
                }
                if (GUILayout.Button("Erase Backup", STYLE_DELETE_BUTTON))
                {
                    SAVE.manager.EraseBackupSet(backupSet);
                    display       = DISPLAY.HIDDEN;
                    deleteEnabled = false;
                }
                GUI.enabled = true;
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Cancel"))
                {
                    display       = DISPLAY.HIDDEN;
                    deleteEnabled = false;
                }
                GUI.enabled = backups.Length > 0;
                if (GUILayout.Button("RESTORE"))
                {
                    if (SAVE.manager.RestoreGame(game, backup))
                    {
                        display       = DISPLAY.RESTORING;
                        deleteEnabled = false;
                    }
                }
                GUI.enabled = true;
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }
        public void UpdateSelectedBackupSets()
        {
            this.backupSetsFilterInfo.Clear();
            var selectedBackupSetsFromClient = this.RestoreParams.SelectedBackupSets;

            if (this.RestorePlan != null && this.RestorePlan.RestoreOperations != null)
            {
                for (int index = 0; index < this.RestorePlan.RestoreOperations.Count; index++)
                {
                    BackupSet backupSet = this.RestorePlan.RestoreOperations[index].BackupSet;
                    if (backupSet != null)
                    {
                        // If the collection client sent is null, select everything; otherwise select the items that are selected in client
                        bool backupSetSelected = selectedBackupSetsFromClient == null || selectedBackupSetsFromClient.Any(x => BackUpSetGuidEqualsId(backupSet, x));

                        if (backupSetSelected)
                        {
                            AddBackupSetsToSelected(index, index);

                            //the last index - this will include tail-Log restore operation if present
                            //If the last item is selected, select all the items before that because the last item
                            //is tail-log
                            if (index == this.RestorePlan.RestoreOperations.Count - 1)
                            {
                                AddBackupSetsToSelected(0, index);
                            }

                            //If the second item is selected and it's a diff backup, the fist item (full backup) has to be selected
                            if (index == 1 && backupSet.BackupSetType == BackupSetType.Differential)
                            {
                                AddBackupSetsToSelected(0, 0);
                            }

                            //If the selected item is a log backup, select all the items before that
                            if (backupSet.BackupSetType == BackupSetType.Log)
                            {
                                AddBackupSetsToSelected(0, index);
                            }
                        }
                        else
                        {
                            // If the first item is not selected which is always the full backup, other backupsets cannot be selected
                            if (index == 0)
                            {
                                selectedBackupSetsFromClient = new string[] { };
                            }

                            //The a log is not selected, the logs after that cannot be selected
                            if (backupSet.BackupSetType == BackupSetType.Log)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Adds backup set to selected list if not added aleady
 /// </summary>
 /// <param name="backupSet"></param>
 public void Add(BackupSet backupSet)
 {
     if (backupSet != null)
     {
         if (!this.selectedBackupSets.Contains(backupSet.BackupSetGuid))
         {
             this.selectedBackupSets.Add(backupSet.BackupSetGuid);
         }
     }
 }
 /// <summary>
 /// Method to invoke when the AddBackupSet command is executed.
 /// </summary>
 private void OnAddBackupSetExecute()
 {
     var BackupSet = new BackupSet();
     // Note that we use the type factory here because it will automatically take care of any dependencies
     // that the BackupSetViewModel will add in the future
     var typeFactory = this.GetTypeFactory();
     var BackupSetViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion<BackupSetViewModel>(BackupSet);
     if (_uiVisualizerService.ShowDialog(BackupSetViewModel) ?? false)
     {
         BackupSets.Add(BackupSet);
     }
 }
Esempio n. 10
0
 private void AddBackupSetsToSelected(int from, int to)
 {
     if (this.RestorePlan != null && this.RestorePlan.RestoreOperations != null &&
         from < this.RestorePlan.RestoreOperations.Count && to < this.RestorePlan.RestoreOperations.Count)
     {
         for (int i = from; i <= to; i++)
         {
             BackupSet backupSet = this.RestorePlan.RestoreOperations[i].BackupSet;
             this.backupSetsFilterInfo.Add(backupSet);
         }
     }
 }
Esempio n. 11
0
        public BackupSet GetById(int id)
        {
            using (dbc = DAL.Instance.GetDb()){
                BackupSet bs = dbc.Select <BackupSet>(b => b.Id == id && b.Enabled)[0];

                /* && b.Generation == (dbc.GetScalar<BackupSet, int>(sbs =>  Sql.Max(sbs.Generation), sbs => sbs.Id == id))
                 *      )[0];*/

                bs.ScheduleTimes.AddRange(new ScheduleDAO().GetForBS(id));
                return(bs);
            }
        }
        /// <summary>
        /// Method to invoke when the AddBackupSet command is executed.
        /// </summary>
        private void OnAddBackupSetExecute()
        {
            var BackupSet = new BackupSet();
            // Note that we use the type factory here because it will automatically take care of any dependencies
            // that the BackupSetViewModel will add in the future
            var typeFactory        = this.GetTypeFactory();
            var BackupSetViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <BackupSetViewModel>(BackupSet);

            if (_uiVisualizerService.ShowDialog(BackupSetViewModel) ?? false)
            {
                BackupSets.Add(BackupSet);
            }
        }
Esempio n. 13
0
        private static void InitializeData(string setupPassword)
        {
            // node group with ID=0 mandatory, so it's the very first object to create
            NodeGroup defaultNG = new NodeGroup();

            defaultNG.Description = "Default group";
            defaultNG.Name        = "Default";
            new DAL.NodeGroupDAO().Save(defaultNG);

            Password adminP = new Password();

            adminP.Value = setupPassword;
            adminP       = PasswordManager.Add(adminP);

            User admin = new User();

            admin.Login = "******";
            admin.Name  = "Superadmin user";
            admin.Email = "*****@*****.**";
            //admin.Roles.Add(new UserRole{Role = RoleEnum.SuperAdmin});
            admin.IsEnabled = true;
            var adminRole = new UserRole();

            adminRole.Role         = RoleEnum.SuperAdmin;
            adminRole.GroupsInRole = new List <int> {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            admin.PasswordId = adminP.Id;
            admin.Roles      = new List <UserRole>();
            admin.Roles.Add(adminRole);

            admin = new DAL.UserDAO().Save(admin);

            BackupSet dummy = new BackupSet();

            dummy.IsTemplate  = true;
            dummy.Name        = "Default BackupSet";
            dummy.Operation   = TaskOperation.Backup;
            dummy.Parallelism = new Parallelism()
            {
                Kind = ParallelismLevel.Disk, Value = 2
            };
            dummy.RetentionDays = 7;
            BasePath dp = new BasePath();

            dp.Path      = "*";
            dp.Recursive = true;
            dp.Type      = "FS:local";
            dummy.BasePaths.Add(dp);
            dummy = new DAL.BackupSetDAO().Save(dummy);
        }
Esempio n. 14
0
            public override bool Equals(System.Object right)
            {
                if (right == null)
                {
                    return(false);
                }
                BackupSet cmp = right as BackupSet;

                if (cmp == null)
                {
                    return(false);
                }
                return(name.Equals(cmp.name));
            }
Esempio n. 15
0
 public BackupSet Save(BackupSet bs)
 {
     using (dbc = DAL.Instance.GetDb()){
         bs.Id         = IdManager.GetId();
         bs.Generation = 0;
         dbc.Insert(bs);
         foreach (ScheduleTime st in bs.ScheduleTimes)
         {
             st.BackupSetId = bs.Id;
         }
         new ScheduleDAO().Save(bs.ScheduleTimes);
     }
     return(bs);
 }
Esempio n. 16
0
 private int GetFirstSelectedBackupSetIndex()
 {
     if (this.RestorePlan != null && this.RestorePlan.RestoreOperations.Any() && this.backupSetsFilterInfo.AnySelected)
     {
         for (int i = 0; i < this.RestorePlan.RestoreOperations.Count - 1; i++)
         {
             BackupSet backupSet = this.RestorePlan.RestoreOperations[i].BackupSet;
             if (this.backupSetsFilterInfo.IsBackupSetSelected(backupSet))
             {
                 return(i);
             }
         }
     }
     return(-1);
 }
Esempio n. 17
0
 /// <summary>
 /// 系统备份
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void barButtonItem10_ItemClick(object sender, ItemClickEventArgs e)
 {
     saveFileDialog1.Filter           = "bin files(*.bin)|*.bin|All files (*.*)|*.*";
     saveFileDialog1.RestoreDirectory = true;
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         SplashScreenManager.ShowDefaultWaitForm("正在备份", "请稍候....");
         string fname;
         fname = saveFileDialog1.FileName;
         BackupSet bset = new BackupSet();
         bset.Backup(fname);
         SplashScreenManager.CloseDefaultWaitForm();
         XtraMessageBox.Show("备份成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 18
0
        private bool TasksQueueExists(BackupSet bs)
        {
            var list = from Task t in TasksQueue
                       where t.BackupSet.Id == bs.Id &&
                       t.RunStatus != TaskRunningStatus.Cancelling &&
                       t.RunStatus != TaskRunningStatus.Cancelled &&
                       t.RunStatus != TaskRunningStatus.Done
                       select t;

            if (list.Count() == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public void RunBackupTest()
        {
            try
            {
                var bs = new BackupSet("TEST", @"C:\Test1", @"C:\Test3");
                Assert.IsTrue(bs.Status == "Ready.");
                bs.RunBackup();

                while (bs.Status != "Finished.")
                {
                    Thread.Sleep(100);
                }
                Assert.IsTrue(bs.FileCopyCount + bs.FileOverwriteCount + bs.FileSkipCount == bs.TotalFileCount, "File counts don't add up");
                Assert.IsTrue(bs.TotalFileCountMaximum == bs.TotalFileCount, "Didn't react maximum count");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Esempio n. 20
0
        public void RunBackupTest()
        {
            try
            {
                var bs = new BackupSet("TEST", @"C:\Test1", @"C:\Test3");
                Assert.IsTrue(bs.Status == "Ready.");
                bs.RunBackup();

                while (bs.Status != "Finished.")
                {
                    Thread.Sleep(100);
                }
                Assert.IsTrue(bs.FileCopyCount + bs.FileOverwriteCount + bs.FileSkipCount == bs.TotalFileCount, "File counts don't add up");
                Assert.IsTrue(bs.TotalFileCountMaximum == bs.TotalFileCount, "Didn't react maximum count");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Esempio n. 21
0
        private Task CreateTask(BackupSet bs, TaskStartupType taskType, User u, BackupLevel?overridenLevel)
        {
            if (TasksQueueExists(bs))
            {
                return(null);
            }
            Task newBackup = new Task(bs, taskType);

            newBackup.Operation     = bs.Operation;
            newBackup.NodeId        = bs.NodeId;
            newBackup.CurrentAction = "Initializing";
            newBackup.RunStatus     = TaskRunningStatus.PendingStart;
            newBackup.StartDate     = DateTime.Now;

            if (overridenLevel.HasValue)
            {
                newBackup.Level = overridenLevel.Value;
            }
            else if (bs.ScheduleTimes.Count == 1)
            {
                newBackup.Level = bs.ScheduleTimes[0].Level;
            }
            else
            {
                newBackup.Level = BackupLevel.Refresh;
            }

            if (u != null)
            {
                newBackup.UserId = u.Id;
                Logger.Append("HUBRN", Severity.DEBUG, "User " + u.Id + " (" + u.Name + ") started new task for backupset " + bs.Id + " with level " + newBackup.Level + " (client #" + bs.NodeId + ")");
            }
            // set an encryption key
            newBackup.EncryptionKey = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
            newBackup = new DAL.TaskDAO().Save(newBackup);
            TasksQueue.Add((Task)newBackup);
            Logger.Append("RUN", Severity.TRIVIA, "Created new task for scheduled backupset " + bs.ToString());
            TaskPublisher.Instance().Notify(newBackup);
            return(newBackup);
        }
Esempio n. 22
0
        public IEnumerable <BackupSetInfo> GetBackupSetInfo()
        {
            List <BackupSetInfo> result = new List <BackupSetInfo>();

            foreach (Restore restore in RestorePlan.RestoreOperations)
            {
                BackupSet backupSet = restore.BackupSet;

                String bkSetComponent;
                String bkSetType;
                CommonUtilities.GetBackupSetTypeAndComponent(backupSet.BackupSetType, out bkSetType, out bkSetComponent);

                if (this.Server.Version.Major > 8 && backupSet.IsCopyOnly)
                {
                    bkSetType += " (Copy Only)";
                }
                result.Add(new BackupSetInfo {
                    BackupComponent = bkSetComponent, BackupType = bkSetType
                });
            }

            return(result);
        }
Esempio n. 23
0
 public RestoreJob(BackupSet set, String name)
 {
     this.set  = set;
     this.name = name;
 }
Esempio n. 24
0
 public int CompareTo(BackupSet right)
 {
     return(name.CompareTo(right.name));
 }
Esempio n. 25
0
 public BackupSet Post(BackupSet bs)
 {
     return(RemotingManager.GetRemoteObject().CreateBackupSet(bs));
 }
Esempio n. 26
0
 public BackupSet Put(BackupSet req)
 {
     return(RemotingManager.GetRemoteObject().UpdateBackupSet(req));
 }
Esempio n. 27
0
        /*public BackupSet Get(GetBs req){
         *      return RemotingManager.GetRemoteObject().GetBackupSet(req.Id);
         * }*/

        public BackupSet Get(BackupSet req)
        {
            return(RemotingManager.GetRemoteObject().GetBackupSet(req.Id));
        }
Esempio n. 28
0
 //[PrincipalPermission(SecurityAction.Demand, Role="Admin")]
 public BackupSet CreateBackupSet(BackupSet bs)
 {
     //DBHandle db = new DBHandle();
     //db.AddBackupSet(bs);
     return(new DAL.BackupSetDAO(sessionUser).Save(bs));
 }
Esempio n. 29
0
 /// <summary>
 /// Returns true if given backup set is selected
 /// </summary>
 public bool IsBackupSetSelected(BackupSet backupSet)
 {
     return(IsBackupSetSelected(backupSet != null ? backupSet.BackupSetGuid : Guid.Empty));
 }
Esempio n. 30
0
 public BackupSet UpdateBackupSet(BackupSet bs)
 {
     return(new DAL.BackupSetDAO(sessionUser).Update(bs));
 }
 public void CreatesWithDefaults()
 {
     BackupSet bs = new BackupSet("TEST");
     Assert.IsTrue(bs.Name == "TEST");
 }
Esempio n. 32
0
 public BackupJob(BackupSet set)
 {
     this.set       = set;
     this.completed = (set == null); // nothing todo means completed
 }
Esempio n. 33
0
        public void ToggleSelectRestore(int index)
        {
            RestorePlan rp = this.restorePlan;

            if (rp == null || rp.RestoreOperations.Count <= index)
            {
                return;
            }
            //the last index - this will include tail-Log restore operation if present
            if (index == rp.RestoreOperations.Count - 1)
            {
                if (this.RestoreSelected[index])
                {
                    this.RestoreSelected[index] = false;
                }
                else
                {
                    for (int i = 0; i <= index; i++)
                    {
                        this.RestoreSelected[i] = true;
                    }
                }
                return;
            }
            if (index == 0)
            {
                if (!this.RestoreSelected[index])
                {
                    this.RestoreSelected[index] = true;
                }
                else
                {
                    for (int i = index; i < rp.RestoreOperations.Count; i++)
                    {
                        this.RestoreSelected[i] = false;
                    }
                }
                return;
            }

            if (index == 1 && rp.RestoreOperations[index].BackupSet.BackupSetType == BackupSetType.Differential)
            {
                if (!this.RestoreSelected[index])
                {
                    this.RestoreSelected[0]     = true;
                    this.RestoreSelected[index] = true;
                }
                else if (rp.RestoreOperations[2].BackupSet == null)
                {
                    this.RestoreSelected[index] = false;
                    this.RestoreSelected[2]     = false;
                }
                else if (this.Server.Version.Major < 9 || BackupSet.IsBackupSetsInSequence(rp.RestoreOperations[0].BackupSet, rp.RestoreOperations[2].BackupSet))
                {
                    this.RestoreSelected[index] = false;
                }
                else
                {
                    for (int i = index; i < rp.RestoreOperations.Count; i++)
                    {
                        this.RestoreSelected[i] = false;
                    }
                }
                return;
            }
            if (rp.RestoreOperations[index].BackupSet.BackupSetType == BackupSetType.Log)
            {
                if (this.RestoreSelected[index])
                {
                    for (int i = index; i < rp.RestoreOperations.Count; i++)
                    {
                        this.RestoreSelected[i] = false;
                    }
                    return;
                }
                else
                {
                    for (int i = 0; i <= index; i++)
                    {
                        this.RestoreSelected[i] = true;
                    }
                    return;
                }
            }
        }
Esempio n. 34
0
        public void CreatesWithDefaults()
        {
            BackupSet bs = new BackupSet("TEST");

            Assert.IsTrue(bs.Name == "TEST");
        }