public BackupBaseFileSystem(BackupProfileData profile) { m_Profile = profile; m_IStorage = profile.GetStorageInterface(); m_Logger = profile.Logger; m_BackupSessionHistory = new BackupSessionHistory(profile.GetStorageInterface()); }
public BackupBase(BackupProfileData profile, GenericStatusBarView progressBar) : base(profile) { m_TimeStamp = DateTime.Now; m_Profile = profile; m_IStorage = profile.GetStorageInterface(); m_Logger = profile.Logger; m_SourceBackupPathList = profile.BackupFolderList.ToList();//.Where(i => i.IsAvailable).ToList(); m_TargetBackupPath = profile.GetTargetBackupFolder(); m_ProgressBar = progressBar; }
FileSystemWatcherWorkerTask(BackupProfileData profile, long wakeupIntervalSec) { m_Profile = profile; m_Logger = profile.Logger; WorkerReportsProgress = true; WorkerSupportsCancellation = true; DoWork += (sender, e) => { //var watchList = profile.BackupWatcherItemList; try { //watchList.Clear(); foreach (var backupItem in profile.BackupFolderList) { m_Logger.Writeln($"Starting File System Watcher: {backupItem.Path}"); try { new FileSystemWatcerItemManager(m_Profile).RunWatcher(backupItem.Path); } catch (FileNotFoundException) { m_Logger.Writeln($"***Warning: Backup item not available: {backupItem.Path}"); } } } catch (TaskCanceledException ex) { m_Logger.Writeln($"File System Watcher exception: {ex.Message}"); Trace.WriteLine($"File System Watcher exception: {ex.Message}"); e.Result = $"Full Backup exception: {ex.Message}"; throw (ex); } finally { } }; m_FileSystemWatcherBackupTimer = new FileSystemProfileBackupWatcherTimer() { Profile = profile, Interval = wakeupIntervalSec, AutoReset = true, Enabled = profile.IsWatchFileSystem, }; m_FileSystemWatcherBackupTimer.Elapsed += BackupTaskManager.OnFileSystemWatcherBackupTimerStartBackup; }
//public void SaveHistoryItem(string path, HistoryItem item) //{ // var fileName = m_Storage.GetFileName(path); // var directory = m_Storage.GetDirectoryName(path); // var historyDir = m_Storage.Combine(directory, HistoryDirectory); // m_Storage.CreateDirectory(historyDir); // var destPath = m_Storage.Combine(historyDir, fileName + "_history.json"); // string json = json = JsonConvert.SerializeObject(item, Formatting.Indented); // File.WriteAllText(destPath, json); //} public void SaveHistory(BackupPerfectLogger logger = null) { var m_IStorage = new FileSystemStorage(); var fullPath = m_IStorage.Combine(HistoryData.TargetPath, HistoryData.SessionSignature); var historyDir = m_IStorage.Combine(fullPath, HistoryDirectory); m_IStorage.CreateDirectory(historyDir); string historyFile = m_IStorage.Combine(historyDir, $"{HistoryData.SessionSignature}_history.json"); var historyData = new object[1]; historyData[0] = this; string json = json = JsonConvert.SerializeObject(historyData, Formatting.Indented); File.WriteAllText(historyFile, json); }
public FileSystemWatcerItemManager(BackupProfileData profile) { m_Profile = profile; m_Logger = profile.Logger; }
public BackupAlertManager(BackupProfileData profile) { m_Profile = profile; m_Logger = profile.Logger; }
public BackupProcessWorkerTask(BackupProfileData profile, bool bFullBackupScan) { m_Profile = profile; m_Logger = profile.Logger; m_bFullBackupScan = bFullBackupScan; WorkerReportsProgress = true; WorkerSupportsCancellation = true; DoWork += (sender, e) => { m_MaxActiveCPU = Properties.General.Default.MaxCPUOnBusy; m_MaxIdleCPU = Properties.General.Default.MaxCPUOnAway; m_ProgressBar = GenericStatusBarView.NewInstance; profile.IsBackupWorkerBusy = true; // RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackupTaskRunWorkerCompletedEvent); ProgressChanged += BackupTaskRunWorkerProgressChangedEvent; RunWorkerCompleted += BackupTaskRunWorkerCompletedEvent; //profile.IsBackupWorkerBusy = true; m_ProgressBar.UpdateProgressBar("Backup starting...", 0); var startTime = DateTime.Now; m_Logger.Writeln($"-------------------------------------------------"); try { switch (profile.BackupType) { case BackupTypeEnum.Differential: if (bFullBackupScan) { m_Logger.Writeln($"Starting a Full Deep Differential backup"); m_BackupManager = new DifferentialBackup(profile, m_ProgressBar); } else { m_Logger.Writeln($"Starting a Differential watcher backup"); m_BackupManager = new DifferentialWatcherBackup(profile, m_ProgressBar); } break; case BackupTypeEnum.Incremental: if (bFullBackupScan) { m_Logger.Writeln($"Starting a Full Deep Incremental backup"); m_BackupManager = new IncrementalFullBackup(profile, m_ProgressBar); } else { m_Logger.Writeln($"Starting Incremental watcher backup"); m_BackupManager = new IncrementalFullWatcherBackup(profile, m_ProgressBar); } break; case BackupTypeEnum.Snapshot: m_Logger.Writeln($"Starting a Snapshot backup"); m_BackupManager = new SnapshotBackup(profile, m_ProgressBar); break; default: throw new ArgumentNullException("Unknown backup type in BackupWorker"); } m_BackupManager.Init(); m_BackupManager.ProcessBackup(); m_BackupManager.Done(); m_Profile.RefreshProfileProperties(); } catch (TaskCanceledException ex) { m_Logger.Writeln($"Backup exception: {ex.Message}"); m_ProgressBar.UpdateProgressBar("Completed with Errors"); Trace.WriteLine($"Full Backup exception: {ex.Message}"); e.Result = $"Full Backup exception: {ex.Message}"; throw (ex); } finally { if (CancellationPending) { e.Cancel = true; } m_Logger.Writeln($"Backup completed, execution time: {DateTime.Now - startTime}"); m_ProgressBar.Release(); m_ProgressBar = null; m_BackupManager = null; } }; }