public void BackupTest()
		{
			FbBackup backupSvc = new FbBackup();

			backupSvc.ConnectionString = this.BuildServicesConnectionString();
			backupSvc.BackupFiles.Add(new FbBackupFile(ConfigurationManager.AppSettings["BackupRestoreFile"], 2048));
			backupSvc.Verbose = true;

			backupSvc.Options = FbBackupFlags.IgnoreLimbo;

			backupSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);

			backupSvc.Execute();
		}
Exemple #2
0
 public static void b_(FbConnectionStringBuilder fc,string fbk_)
 {
     is_close = false;
     try
     {
         FbBackupFile fbk = new FbBackupFile(fbk_);
         FbBackup fr = new FbBackup();
         fr.Verbose = true;
         fr.ConnectionString = fc.ConnectionString;
         fr.BackupFiles.Add(fbk);
         fr.Options = FbBackupFlags.NoGarbageCollect;
         fr.ServiceOutput += ServiceOutput;
         fr.Execute();
     }
     catch (FbException ex)
     {
         error = ex.Message;
     }
     finally
     {
         is_close = true;
     }
 }
        public void Backup(string source, string dest)
        {
            if (!File.Exists(source))
                throw new FileNotFoundException("Source file not found", source);

            if (File.Exists(dest))
                throw new IOException("Destination file already exists");

            Debug.WriteLine("Backing up database");
            Debug.WriteLine("Source: {0} ({1})", source, GetFileSize(source));
            Debug.WriteLine("Destination: {0}", dest, null);

            string backupTemp = GetTempName(dest);

            Debug.WriteLine("Backing up to temp file - {0}", backupTemp, null);

            FbBackup backup = new FbBackup
            {
                ConnectionString = CreateConnectionString(source),
                Verbose = true,
            };

            backup.BackupFiles.Add(new FbBackupFile(backupTemp, null));

            backup.ServiceOutput += ServiceOutput;

            backup.Execute();

            Debug.WriteLine("Backup complete - {0} ({1})", backupTemp, GetFileSize(backupTemp));

            Debug.WriteLine("Renaming temp backup file to - {0}", dest, null);

            File.Move(backupTemp, dest);

            Debug.WriteLine("Backup complete");
        }
Exemple #4
0
		public void BackupRestore_A_Backup01Test()
		{
			FbBackup backupSvc = new FbBackup();

			backupSvc.ConnectionString = this.BuildServicesConnectionString();
			backupSvc.Options = FbBackupFlags.IgnoreLimbo;
			backupSvc.BackupFiles.Add(new FbBackupFile(ConfigurationManager.AppSettings["BackupRestoreFile"], 2048));
			backupSvc.Verbose = true;

			backupSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);

			backupSvc.Execute();

			var backup = GetBackupRestoreFullPath();
			Assert.IsNotNull(backup);
			Assert.Greater(new FileInfo(backup).Length, 0);
		}
Exemple #5
0
        private void DBbackupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MainMenu.Enabled = false;
            //Определяемя с базами данных
            int i = 0;
            pbDB.Maximum = CheckedCount();
            pbDB.Value = 0;
            pbDB.Step = 1;
            pbWork.Style = ProgressBarStyle.Marquee;
            pbWork.MarqueeAnimationSpeed = 0;
            foreach (ToolStripMenuItem it in dbTSMI.DropDownItems)
            {

                if (it.Checked)
                {
                    try
                    {
                        string bakname = string.Format(Properties.Settings.Default.DefaultArchives, ".GBK", it.Text, DateTime.Today);
                        lCurrentDB.Text = string.Format("{0}. {1}", (++i), it.Text) + "=>" + bakname;
                        pbDB.PerformStep();
                        PutLog(string.Format("Строчка соединения {0}", it.ToolTipText));
                        pbDB.Update();
                        FbBackup fbb = new FbBackup();
                        fbb.ConnectionString = it.ToolTipText;
                        fbb.BackupFiles.Add(new FbBackupFile(bakname, 2048));
                        fbb.Verbose = true;
                        fbb.Options = FbBackupFlags.IgnoreLimbo; //FbBackupFlags.
                        fbb.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);
                        pbWork.MarqueeAnimationSpeed = 50;
                        Application.DoEvents();
                        fbb.Execute();
                        pbWork.MarqueeAnimationSpeed = 0;
                        toolStripStatusLabel1.Text = it.Text + " OK";
                        Application.DoEvents();
                    }
                    catch (Exception er)
                    {
                        pbWork.ForeColor = Color.Red;
                        PutLog(string.Format("Упс... ошибочка:{0}", er.Message));
                        MessageBox.Show(er.Message, "Ошибочка вышла...");
                        pbWork.ForeColor = pbDB.ForeColor;
                        ThreadExceptionHandler.SendErrorMessage(string.Format("{0}:{1}", it.ToolTipText, er.Message));

                    }
                    pbWork.Value = 0;

                }
            }

            pbDB.Maximum = CheckedCount();
            MainMenu.Enabled = true; pbWork.Style = ProgressBarStyle.Blocks;
            pbWork.MarqueeAnimationSpeed = 0;
            PutLog("Архивация завершена");
        }
		void BackupRestoreTest_BackupPart()
		{
			FbBackup backupSvc = new FbBackup();

			backupSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
			backupSvc.Options = FbBackupFlags.IgnoreLimbo;
			backupSvc.BackupFiles.Add(new FbBackupFile(TestsSetup.BackupRestoreFile, 2048));
			backupSvc.Verbose = true;

			backupSvc.ServiceOutput += new EventHandler<ServiceOutputEventArgs>(ServiceOutput);

			backupSvc.Execute();
		}
        public void Copy(string source, string dest)
        {
            if (!File.Exists(source))
                throw new FileNotFoundException("Source file not found", source);

            if (File.Exists(dest))
                throw new IOException("Destination file already exists");

            Debug.WriteLine("Copying database");
            Debug.WriteLine("Source: {0} ({1})", source, GetFileSize(source));
            Debug.WriteLine("Destination: {0}", dest, null);

            string backupTemp = GetTempName(source);

            Debug.WriteLine("Backing up to temp file - {0}", backupTemp, null);

            FbBackup backup = new FbBackup
            {
                ConnectionString = CreateConnectionString(source),
                Verbose = true,
                Options = FbBackupFlags.NoGarbageCollect,
            };

            backup.BackupFiles.Add(new FbBackupFile(backupTemp, null));

            backup.ServiceOutput += ServiceOutput;

            backup.Execute();

            Debug.WriteLine("Backup complete - {0} ({1})", backupTemp, GetFileSize(backupTemp));

            string restoreTemp = GetTempName(source);

            Debug.WriteLine("Restoring to temp file - {0}", restoreTemp, null);

            FbRestore restore = new FbRestore()
            {
                ConnectionString = CreateConnectionString(restoreTemp),
                Verbose = true,
                Options = FbRestoreFlags.Create,
            };

            restore.BackupFiles.Add(new FbBackupFile(backupTemp, null));

            restore.ServiceOutput += ServiceOutput;

            restore.Execute();

            Debug.WriteLine("Restore complete - {0} ({1})", restoreTemp, GetFileSize(restoreTemp));

            Debug.WriteLine("Renaming temp restore file to - {0}", dest, null);

            File.Move(restoreTemp, dest);

            Debug.WriteLine("Deleting temp backup file - {0}", backupTemp, null);

            File.Delete(backupTemp);

            Debug.WriteLine("Copy complete");
        }