public void NBackupBackupRestoreTest()
        {
            if (!EnsureVersion(new Version("2.5.0.0")))
            {
                return;
            }

            const int Levels     = 2;
            var       backupName = $"{Guid.NewGuid().ToString()}.nbak";

            void BackupPart()
            {
                void DoLevel(int level)
                {
                    var nbak = new FbNBackup();

                    nbak.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
                    nbak.Level            = level;
                    nbak.BackupFile       = backupName + level.ToString();
                    nbak.DirectIO         = true;
                    nbak.Options          = FbNBackupFlags.NoDatabaseTriggers;

                    nbak.ServiceOutput += ServiceOutput;

                    nbak.Execute();
                }

                for (int i = 0; i < Levels; i++)
                {
                    DoLevel(i);
                }
            }

            void RestorePart()
            {
                FbConnection.DropDatabase(BuildConnectionString(FbServerType, Compression));

                var nrest = new FbNRestore();

                nrest.ConnectionString = BuildServicesConnectionString(FbServerType, Compression, true);
                nrest.BackupFiles      = Enumerable.Range(0, Levels).Select(l => backupName + l.ToString());
                nrest.DirectIO         = true;

                nrest.ServiceOutput += ServiceOutput;

                nrest.Execute();
            }

            BackupPart();
            RestorePart();
        }
Ejemplo n.º 2
0
        void NBackupBackupRestoreTest_RestorePart()
        {
            FbConnection.DropDatabase(BuildConnectionString(FbServerType));

            var nrest = new FbNRestore();

            nrest.ConnectionString = BuildServicesConnectionString(FbServerType);
            nrest.BackupFiles      = Enumerable.Range(0, 2).Select(l => TestsSetup.BackupRestoreFile + l.ToString());
            nrest.DirectIO         = true;

            nrest.ServiceOutput += ServiceOutput;

            nrest.Execute();
        }
Ejemplo n.º 3
0
        void NBackupBackupRestoreTest_RestorePart(Guid id)
        {
            FbConnection.DropDatabase(BuildConnectionString(FbServerType, Compression));

            var nrest = new FbNRestore();

            nrest.ConnectionString = BuildServicesConnectionString(FbServerType);
            nrest.BackupFiles      = Enumerable.Range(0, 2).Select(l => CreateBackupFilename(id) + l.ToString());
            nrest.DirectIO         = true;

            nrest.ServiceOutput += ServiceOutput;

            nrest.Execute();
        }
Ejemplo n.º 4
0
        public async Task NBackupBackupRestoreTest()
        {
            if (!EnsureServerVersion(new Version(2, 5, 0, 0)))
            {
                return;
            }

            const int Levels     = 2;
            var       backupName = $"{Guid.NewGuid()}.nbak";

            async Task BackupPart()
            {
                Task DoLevel(int level)
                {
                    var nbak = new FbNBackup();

                    nbak.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);
                    nbak.Level            = level;
                    nbak.BackupFile       = backupName + level.ToString();
                    nbak.DirectIO         = true;
                    nbak.Options          = FbNBackupFlags.NoDatabaseTriggers;
                    nbak.ServiceOutput   += ServiceOutput;
                    return(nbak.ExecuteAsync());
                }

                for (var i = 0; i < Levels; i++)
                {
                    await DoLevel(i);
                }
            }

            Task RestorePart()
            {
                FbConnection.DropDatabase(BuildConnectionString(ServerType, Compression, WireCrypt));
                var nrest = new FbNRestore();

                nrest.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);
                nrest.BackupFiles      = Enumerable.Range(0, Levels).Select(l => backupName + l.ToString());
                nrest.DirectIO         = true;
                nrest.ServiceOutput   += ServiceOutput;
                return(nrest.ExecuteAsync());
            }

            await BackupPart();
            await RestorePart();
        }
Ejemplo n.º 5
0
        public void NBackup_B_NRestoreTest()
        {
            if (GetServerVersion() < new Version("2.5.0.0"))
            {
                Assert.Inconclusive("Not supported on this version.");
                return;
            }

            FbConnection.DropDatabase(BuildConnectionString());

            var nrest = new FbNRestore();

            nrest.ConnectionString = BuildServicesConnectionString();
            nrest.BackupFiles      = Enumerable.Range(0, 2).Select(l => ConfigurationManager.AppSettings["BackupRestoreFile"] + l.ToString());
            nrest.DirectIO         = true;

            nrest.ServiceOutput += ServiceOutput;

            nrest.Execute();
        }