void BackupRestoreTest_RestorePart()
		{
			FbRestore restoreSvc = new FbRestore();

			restoreSvc.ConnectionString = BuildServicesConnectionString(FbServerType);
			restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;
			restoreSvc.PageSize = 4096;
			restoreSvc.Verbose = true;
			restoreSvc.BackupFiles.Add(new FbBackupFile(TestsSetup.BackupRestoreFile, 2048));

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

			restoreSvc.Execute();
		}
Ejemplo n.º 2
0
		public void BackupRestore_B_Restore01Test()
		{
			FbRestore restoreSvc = new FbRestore();

			restoreSvc.ConnectionString = this.BuildServicesConnectionString();
			restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;
			restoreSvc.PageSize = 4096;
			restoreSvc.Verbose = true;
			restoreSvc.BackupFiles.Add(new FbBackupFile(ConfigurationManager.AppSettings["BackupRestoreFile"], 2048));

			restoreSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);

			restoreSvc.Execute();

			// some validation
		}
Ejemplo n.º 3
0
        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");
        }