public void Backup_CanExecuteBackupTask() { DatabaseTargetConfigurationElement config = GetBackupTarget(); BackupTask task = new BackupTask(config); task.Execute(); }
private static void ExecuteBackup(DatabaseTargetConfigurationElement target) { try { BackupTask task = new BackupTask(target); task.BackupComplete += new EventHandler <DatabaseTargetEventArgs>(BackupComplete); task.BackupStart += new EventHandler <DatabaseTargetEventArgs>(BackupStart); task.CompressComplete += new EventHandler <DatabaseTargetEventArgs>(BackupCompressComplete); task.CompressStart += new EventHandler <DatabaseTargetEventArgs>(BackupCompressStart); task.TransferComplete += new EventHandler <DatabaseTargetEventArgs>(BackupTransferComplete); task.TransferProgress += new EventHandler <DatabaseTargetEventArgs>(BackupTransferProgress); task.TransferStart += new EventHandler <DatabaseTargetEventArgs>(BackupTransferStart); var result = task.Execute(); if (!result.Success) { WriteError(result.Exception); } } catch (Exception ex) { WriteError(ex); } }
public void Backup_CanUploadDatabaseBackup() { DatabaseTargetConfigurationElement config = GetBackupTarget(); BackupTask task = new BackupTask(config); string path = task.BackupDatabase(); task.UploadBackup(path); }
public void Backup_CanBackupDatabase() { DatabaseTargetConfigurationElement config = GetBackupTarget(); BackupTask task = new BackupTask(config); string path = task.BackupDatabase(); Assert.IsTrue(File.Exists(path)); }
/// <summary> /// Initializes a new instance of the BackupTask class. /// </summary> /// <param name="target">The backup target to execute.</param> public BackupTask(DatabaseTargetConfigurationElement target) : base(SThreeQLConfiguration.Section.AwsTargets[target.AwsBucketName]) { this.Target = target; }
/// <summary> /// Fires an event for this instance. /// </summary> /// <param name="handler">The event handler to fire.</param> /// <param name="schedule">The schedule to fire the event for.</param> /// <param name="target">The target to fire the event for, if applicable.</param> /// <param name="exception">The exeption to fire the event for, if applicable.</param> private void Fire(EventHandler <ScheduleEventArgs> handler, ScheduleConfigurationElement schedule, DatabaseTargetConfigurationElement target, Exception exception) { if (handler != null) { ScheduleEventArgs args = new ScheduleEventArgs() { ErrorException = exception, Name = schedule.Name, RepeatType = schedule.Repeat, StartDate = schedule.StartDate }; if (target != null) { args.OperationType = target is DatabaseRestoreTargetConfigurationElement ? ScheduleOperationType.Restore : ScheduleOperationType.Backup; args.TargetName = target.Name; } handler(this, args); } }
private void ExecuteSchedule(object schd) { ScheduleConfigurationElement schedule = (ScheduleConfigurationElement)schd; this.Fire(this.ScheduleStart, schedule, null, null); foreach (ScheduleTargetConfigurationElement target in schedule.BackupTargets) { DatabaseTargetConfigurationElement config = null; try { config = SThreeQLConfiguration.Section.BackupTargets[target.Name]; BackupTask task = new BackupTask(config); task.BackupComplete += new EventHandler <DatabaseTargetEventArgs>(this.OnBackupComplete); task.BackupStart += new EventHandler <DatabaseTargetEventArgs>(this.OnBackupStart); task.CompressComplete += new EventHandler <DatabaseTargetEventArgs>(this.OnBackupCompressComplete); task.CompressStart += new EventHandler <DatabaseTargetEventArgs>(this.OnBackupCompressStart); task.TransferComplete += new EventHandler <DatabaseTargetEventArgs>(this.OnBackupTransferComplete); task.TransferProgress += new EventHandler <DatabaseTargetEventArgs>(this.OnBackupTransferProgress); task.TransferStart += new EventHandler <DatabaseTargetEventArgs>(this.OnTransferStart); task.Execute(); } catch (Exception ex) { this.Fire(this.ScheduleError, schedule, config, ex); } } foreach (ScheduleTargetConfigurationElement target in schedule.RestoreTargets) { DatabaseRestoreTargetConfigurationElement config = null; try { config = SThreeQLConfiguration.Section.RestoreTargets[target.Name]; RestoreTask task = new RestoreTask(config); task.DecompressComplete += new EventHandler <RestoreDatabaseTargetEventArgs>(this.OnRestoreDecompressComplete); task.DecompressStart += new EventHandler <RestoreDatabaseTargetEventArgs>(this.OnRestoreDecompressStart); task.RestoreComplete += new EventHandler <RestoreDatabaseTargetEventArgs>(this.OnRestoreComplete); task.RestoreStart += new EventHandler <RestoreDatabaseTargetEventArgs>(this.OnRestoreStart); task.TransferComplete += new EventHandler <RestoreDatabaseTargetEventArgs>(this.OnRestoreTransferComplete); task.TransferProgress += new EventHandler <RestoreDatabaseTargetEventArgs>(this.OnRestoreTransferProgress); task.TransferStart += new EventHandler <RestoreDatabaseTargetEventArgs>(this.OnRestoreTransferStart); task.Execute(); } catch (Exception ex) { this.Fire(this.ScheduleError, schedule, config, ex); } } this.Fire(this.ScheduleComplete, schedule, null, null); lock (this) { this.inProgress.Remove(schedule.Name); this.pending.Add(schedule.Name, GetNextExecuteDate(schedule)); } }