Пример #1
0
        public void TestNoDiff()
        {
            var catalog = BackupFileCatalog.CreateDefaultMonthDayDayCatalog(TestSession.TestDbBackupDir.FullName);

            var databaseName   = "test";
            var sqlServerProxy = new TestSqlServerProxy(catalog.NamingConvention.BackupFileNamingConvention, databaseName);
            var planner        = new RestorePlanner(catalog, sqlServerProxy, databaseName);

            var logBackupsToSpan        = 3;
            var minutesAfterFirstBackup = TestSqlServerProxy.BackupIntervalMinutes * logBackupsToSpan;
            var targetTime = TestSession.StartDate.Add(TestSqlServerProxy.FirstBackupTime).AddMinutes(minutesAfterFirstBackup);

            var itemsToRestore = planner.CreatePlan(targetTime);

            Assert.IsNotNull(itemsToRestore);

            // 1 full followed by planned number of log backups plus 1, because must take first log following target time
            Assert.AreEqual(logBackupsToSpan + 2, itemsToRestore.Count);
            Assert.AreEqual(BackupType.Full, itemsToRestore[0].BackupType);
            Assert.AreEqual(BackupType.Log, itemsToRestore[1].BackupType);

            var expectedLastLogBackupStartTime = TestSession.StartDate.Add(TestSqlServerProxy.FirstBackupTime)
                                                 .AddMinutes((logBackupsToSpan + 1) * TestSqlServerProxy.BackupIntervalMinutes);

            Assert.AreEqual(expectedLastLogBackupStartTime, itemsToRestore.Last().BackupStartTime);
        }
Пример #2
0
        public void TestTargetNonWorkHours()
        {
            var catalog = BackupFileCatalog.CreateDefaultMonthDayDayCatalog(TestSession.TestDbBackupDir.FullName);

            var databaseName   = "test";
            var sqlServerProxy = new TestSqlServerProxy(catalog.NamingConvention.BackupFileNamingConvention, databaseName);
            var planner        = new RestorePlanner(catalog, sqlServerProxy, databaseName);

            var targetTime = TestSession.StartDate.AddMonths(1).AddDays(2).Add(TestSqlServerProxy.FirstBackupTime).AddHours(-1);

            var itemsToRestore = planner.CreatePlan(targetTime);

            Assert.IsNotNull(itemsToRestore);

            // 1 full, then diff followed by all log backups in the day plus 1, because must take first log following target time
            Assert.AreEqual(TestSqlServerProxy.LogBackupsPerDay + 2 + 1, itemsToRestore.Count);
            Assert.AreEqual(BackupType.Full, itemsToRestore[0].BackupType);
            Assert.AreEqual(BackupType.DifferentialDatabase, itemsToRestore[1].BackupType);
            Assert.AreEqual(BackupType.Log, itemsToRestore[2].BackupType);

            var expectedLastLogBackupStartTime = TestSession.StartDate.AddMonths(1).AddDays(2).Add(TestSqlServerProxy.FirstBackupTime)
                                                 .AddMinutes(TestSqlServerProxy.BackupIntervalMinutes);

            Assert.AreEqual(expectedLastLogBackupStartTime, itemsToRestore.Last().BackupStartTime);
        }
Пример #3
0
        //[Test]
        public void RealPlannerScratchPad()
        {
            var catalog        = BackupFileCatalog.CreateDefaultMonthDayDayCatalog(@"F:\temp\backup\DOCUMENTS");
            var databaseName   = "DOCUMENTS";
            var sqlServerProxy = new SqlServer2014Proxy(TestSession.Server);

            var planner     = new RestorePlanner(catalog, sqlServerProxy, databaseName);
            var backupItems = planner.CreatePlan(null);

            Assert.That(backupItems, Is.Not.Empty);
        }
Пример #4
0
        public void TestLatest()
        {
            var catalog = BackupFileCatalog.CreateDefaultMonthDayDayCatalog(TestSession.TestDbBackupDir.FullName);

            var databaseName   = "test";
            var sqlServerProxy = new TestSqlServerProxy(catalog.NamingConvention.BackupFileNamingConvention, databaseName);
            var planner        = new RestorePlanner(catalog, sqlServerProxy, databaseName);

            var itemsToRestore = planner.CreatePlan(null);

            Assert.IsNotNull(itemsToRestore);

            // full month of backups, every day starting with full or diff backup, then full day of log backups
            Assert.AreEqual(TestSqlServerProxy.LogBackupsPerDay + 2, itemsToRestore.Count);
            Assert.AreEqual(BackupType.Full, itemsToRestore[0].BackupType);
            Assert.AreEqual(BackupType.DifferentialDatabase, itemsToRestore[1].BackupType);
            Assert.AreEqual(BackupType.Log, itemsToRestore[2].BackupType);

            var expectedLastLogBackupStartTime = TestSession.StartDate.AddMonths(TestSession.TestBckupPeriodMonths).AddDays(-1).Add(TestSqlServerProxy.LastBackupTime);

            Assert.AreEqual(expectedLastLogBackupStartTime, itemsToRestore.Last().BackupStartTime);
        }