public void Execute(object ignored) { try { log.InfoFormat("Starting backup of '{0}' to '{1}'", src, to); var directoryBackups = new List <DirectoryBackup> { new DirectoryBackup(Path.Combine(src, "IndexDefinitions"), Path.Combine(to, "IndexDefinitions")) }; directoryBackups.AddRange(from index in Directory.GetDirectories(Path.Combine(src, "Indexes")) let fromIndex = Path.Combine(src, "Indexes", Path.GetFileName(index)) let toIndex = Path.Combine(to, "Indexes", Path.GetFileName(index)) select new DirectoryBackup(fromIndex, toIndex)); foreach (var directoryBackup in directoryBackups) { directoryBackup.Notify += UpdateBackupStatus; directoryBackup.Prepare(); } foreach (var directoryBackup in directoryBackups) { directoryBackup.Execute(); } var esentBackup = new EsentBackup(instance, to); esentBackup.Notify += UpdateBackupStatus; esentBackup.Execute(); } catch (Exception e) { log.Error("Failed to complete backup", e); UpdateBackupStatus("Failed to complete backup because: " + e.Message); } finally { CompleteBackup(); } }
public void Execute(object ignored) { try { log.InfoFormat("Starting backup of '{0}' to '{1}'", src, to); var directoryBackups = new List<DirectoryBackup> { new DirectoryBackup(Path.Combine(src, "IndexDefinitions"), Path.Combine(to, "IndexDefinitions")) }; directoryBackups.AddRange(from index in Directory.GetDirectories(Path.Combine(src, "Indexes")) let fromIndex = Path.Combine(src, "Indexes", Path.GetFileName(index)) let toIndex = Path.Combine(to, "Indexes", Path.GetFileName(index)) select new DirectoryBackup(fromIndex, toIndex)); foreach (var directoryBackup in directoryBackups) { directoryBackup.Notify += UpdateBackupStatus; directoryBackup.Prepare(); } foreach (var directoryBackup in directoryBackups) { directoryBackup.Execute(); } var esentBackup = new EsentBackup(instance, to); esentBackup.Notify+=UpdateBackupStatus; esentBackup.Execute(); } catch (Exception e) { log.Error("Failed to complete backup", e); UpdateBackupStatus("Faile to complete backup because: " + e.Message); } finally { CompleteBackup(); } }