void reserveFileForBackupImage() { _log.ProcedureCall("reserveFileForBackupImage"); string templateFileName = Path.Combine(Directories.TempFolder, "Backup{0}-" + DateTime.Now.ToString("dddd - dd - MMMM.yyyy HH.mm.ss", CultureInfo.InvariantCulture) + Files.ImageFilesExtension); for (int id = 0; id < Int32.MaxValue; id++) { string fileName; if (id > 0) { fileName = string.Format(templateFileName, id, CultureInfo.InvariantCulture); } else { fileName = string.Format(templateFileName, string.Empty, CultureInfo.InvariantCulture); } if (_imageFile.TrySyncFile(fileName)) { return; } } throw new InvalidOperationException("Fatal Error: could not reserve file name"); }
public override void Open(LogBase log) { if (log == null) { throw new ArgumentNullException("log"); } log.ProcedureCall("Open"); Log = log; if (DeleteBUtilFilesInDestinationFolderBeforeBackup) { log.WriteLine(LoggingEvent.Debug, string.Format(CultureInfo.CurrentCulture, _DeletingBUtilImagesInTargetFolderBeforeBackup, DestinationFolder)); string [] filesToDelete = null; try { filesToDelete = Directory.GetFiles(DestinationFolder, "*" + Files.ImageFilesExtension); } catch (DirectoryNotFoundException e) { log.WriteLine(LoggingEvent.Warning, e.Message); return; } if (filesToDelete.Length > 0) { for (int i = 0; i < filesToDelete.Length; i++) { log.WriteLine(LoggingEvent.Debug, "X " + filesToDelete[i]); try { File.Delete(filesToDelete[i]); } catch (UnauthorizedAccessException e) { log.WriteLine(LoggingEvent.Warning, string.Format(CultureInfo.CurrentCulture, _CANNOTDELETEDUETOACESSVIOLATIONS, filesToDelete[i], e.Message)); } } } } }
public override void Open(LogBase log) { log.ProcedureCall("Open"); Log = log; _connection = new FtpConnection(); _connection.SetLogOnInformation(User, Password); _connection.ServerLocation = this.RemoteHostServer; _connection.IsPassive = !this.FtpModeIsActive; if (_deleteBUtilFilesInDestinationFolderBeforeBackup) { log.WriteLine(LoggingEvent.Debug, string.Format(CultureInfo.CurrentCulture, _DeletingAllBUtilImageFilesFromTargetFolder, DestinationFolder)); string [] filesToDelete = null; try { filesToDelete = _connection.GetFileList(DestinationFolder); } catch (Exception e) { log.WriteLine(LoggingEvent.Warning, e.Message); return; } foreach (string file in filesToDelete) { if (file.EndsWith(Files.ImageFilesExtension)) { log.WriteLine(LoggingEvent.Debug, "X " + file); try { _connection.DeleteFtp(file); } catch (Exception e) { log.WriteLine(LoggingEvent.Warning, string.Format(CultureInfo.CurrentCulture, _CannotDeleteFileDueToFormatString, file, e.Message)); } } } } }
/// <summary> /// Stops backup process immidietly. This is not secure variant and works fine for storages only. For stopping compression it needs to be reworked /// </summary> public void StopForcibly() { _log.ProcedureCall("StopForcibly::start"); _aborting = true; _log.WriteLine(LoggingEvent.Error, _backupAbortedByUser); // cleaning tasls about copying _afterBackupEventManager.Abort(); _beforeBackupEventManager.Abort(); _compressionManager.Abort(); _copyManager.Abort(); _imageCreationManager.Abort(); // Alarming that all finished if (_onBackupFinished != null) { _onBackupFinished.Invoke(); } }