public async Task BackupAsync(BackupType type) { var extension = "bak"; if (type == BackupType.TransactionLog) { extension = "trn"; } var filename = $"{_settings.Value.Database}-{DateTime.UtcNow:yyyy-MM-dd-HH-mm-ss}-{type}.{extension}"; var backupPath = $"{_settings.Value.BackupPath}/{filename}"; var backupName = $"{_settings.Value.Database}-{type}"; var backupType = "DATABASE"; if (type == BackupType.TransactionLog) { backupType = "LOG"; } var diff = ""; if (type == BackupType.Differential) { diff = "DIFFERENTIAL, "; } var sql = $"BACKUP {backupType} [{_settings.Value.Database}] TO DISK = @backupPath WITH {diff}NOFORMAT, NOINIT, NAME = @backupName, SKIP, NOREWIND, NOUNLOAD, STATS = 10"; _logger.LogInformation($"Backing up {_settings.Value.Database} with type {type}"); await ExecuteAsync(sql, new SqlParameter("backupPath", backupPath), new SqlParameter("backupName", backupName)); _logger.LogInformation($"Back up completed"); }
public static void Backup (string file, string backupDir, BackupType backupType = BackupType.Simple) { if (backupType == BackupType.Off) { return; } if (File.Exists (file) && !IsDirectory (file)) { var backupDirAbs = Path.Combine (Path.GetDirectoryName (file), backupDir); if (!Directory.Exists (backupDirAbs)) { Directory.CreateDirectory (backupDirAbs); } var fileName = Path.GetFileName (file); var backupFile = Path.Combine (backupDirAbs, fileName) + ".~"; if (backupType == BackupType.Simple) { // overwrite previous backup File.Copy (file, backupFile, true); } else if (backupType == BackupType.Numbered) { // backup to the new file var backupNumber = 1; while (File.Exists (backupFile)) { backupFile = Path.Combine (backupDirAbs, fileName) + ".~" + backupNumber + "~"; backupNumber += 1; } File.Copy (file, backupFile); } } }
public void Backup(BackupType backupType) { _logger.ProgressInfo("Starting Backup"); _diskProvider.EnsureFolder(_backupTempFolder); _diskProvider.EnsureFolder(GetBackupFolder(backupType)); var backupFilename = string.Format("radarr_backup_v{0}_{1:yyyy.MM.dd_HH.mm.ss}.zip", BuildInfo.Version, DateTime.Now); var backupPath = Path.Combine(GetBackupFolder(backupType), backupFilename); Cleanup(); if (backupType != BackupType.Manual) { CleanupOldBackups(backupType); } BackupConfigFile(); BackupDatabase(); CreateVersionInfo(); _logger.ProgressDebug("Creating backup zip"); // Delete journal file created during database backup _diskProvider.DeleteFile(Path.Combine(_backupTempFolder, "radarr.db-journal")); _archiveService.CreateZip(backupPath, _diskProvider.GetFiles(_backupTempFolder, SearchOption.TopDirectoryOnly)); _logger.ProgressDebug("Backup zip created"); }
public static string GetBackupDescription(BackupType backupType, bool isFull) { var isFullText = isFull ? "a full" : "an incremental"; var backupTypeText = backupType == BackupType.Snapshot ? "snapshot backup" : "backup"; return($"{isFullText} {backupTypeText}"); }
public static async Task<BackupResultHelper> StartBackup(List<Game> games, BackupType backupType, bool backupEnabled, BackupSyncOptions backupSyncOptions, int intervalMinute = 0, int intervalHour = 0) { //Check for problems with parameters if (!games.Any() && backupType == BackupType.Autobackup && backupEnabled) { _resultHelper = new BackupResultHelper {Message = @"Auto-backup disabled", AutobackupEnabled = false}; return _resultHelper; } if (!games.Any()) { ErrorResultHelper.Message = @"No games selected"; return ErrorResultHelper; } var gamesToBackup= new List<Game>(); if (!backupEnabled) { if (!GetDirectoryOrFile(backupType)) return ErrorResultHelper; gamesToBackup = ModifyGamePaths(games); } switch (backupType) { case BackupType.ToZip: return await BackupToZip.BackupAndZip(gamesToBackup, _specifiedFile); case BackupType.ToFolder: return BackupToFolder.BackupSaves(gamesToBackup, _specifiedFolder); case BackupType.Autobackup: return BackupAuto.ToggleAutoBackup(gamesToBackup, backupEnabled, backupSyncOptions, intervalMinute, intervalHour, _specifiedFolder); } return ErrorResultHelper; }
public async Task <Job> CreateJobForOrganizationAsync(string organizationId, string repositoryId, string name, string description, BackupType backupType, SchedulePolicy schedulePolicy, JobItemCollection selectedItems, string proxyId, bool runNow, CancellationToken ct = default) { ParameterValidator.ValidateNotNull(organizationId, nameof(organizationId)); var bodyParameters = new BodyParameters() .AddOptionalParameter("Name", name) .AddOptionalParameter("Description", description) .AddOptionalParameter("BackupType", backupType) .AddOptionalParameter("SchedulePolicy", schedulePolicy) .AddOptionalParameter("SelectedItems", selectedItems) .AddOptionalParameter("ProxyId", proxyId) .AddMandatoryParameter("RepositoryId", repositoryId) .AddOptionalParameter("RunNow", runNow); var url = $"organizations/{organizationId}/jobs"; return(await _baseClient.PostAsync <Job>(url, bodyParameters, ct)); }
private string DirectoryForBakupType(BackupType lType, string lDestinationPath) { string lSubFolder; switch (lType) { case BackupType.btManual: case BackupType.btManualWithCustomPostfix: lSubFolder = "Manual"; break; case BackupType.btRestore: lSubFolder = "Pre-Restore"; break; default: lSubFolder = ""; break; } if (!String.IsNullOrEmpty(lSubFolder)) { return(Path.Combine(lDestinationPath, lSubFolder + "\\")); } else { return(lDestinationPath); } }
public BackupPolicy ToSDKModel() { BackupPolicy backupPolicy; if (BackupType.Equals(PSBackupPolicy.ContinuousModeBackupType)) { backupPolicy = new ContinuousModeBackupPolicy(); } else { PeriodicModeBackupPolicy periodicModeBackupPolicy = new PeriodicModeBackupPolicy { PeriodicModeProperties = new PeriodicModeProperties() { BackupIntervalInMinutes = BackupIntervalInMinutes, BackupRetentionIntervalInHours = BackupRetentionIntervalInHours, BackupStorageRedundancy = BackupStorageRedundancy } }; backupPolicy = periodicModeBackupPolicy; } return(backupPolicy); }
public BackupResult( string filePath, BackupType backupType ) { _filePath = filePath; _backupType = backupType; }
private static long GetBackupsLimit(Service service, BackupType backupType) { var limit = service.Variables[$"{backupType.ToString()}:LIMIT"] != null ? long.Parse(service.Variables[$"{backupType.ToString().ToUpper()}:LIMIT"].ToString()) : GlobalBackupSettings.GetDefaultCapacity(backupType); return(limit); }
public Tuple <long, BackupType, List <Backup> > GetAllBackupTypesWithBackups(long backupTypeID) { BackupType backupType = FindById(backupTypeID); List <Backup> backups = repositoryBackup.GetAllBackupsOfBackupType(backupTypeID); return(new Tuple <long, BackupType, List <Backup> >(backupTypeID, backupType, backups)); }
public BackupOptions(string server, string user, string password, string database, string toFile, string compression, BackupType type) : base(server, user, password) { Database = database; ToFile = toFile; Compression = compression; Type = type; }
public string GetDefaultTaskName() { var destinations = GetDestinations(); return(destinations.Count == 0 ? $"{BackupType} w/o destinations" : $"{BackupType.ToString()} to {string.Join(", ", destinations)}"); }
public override int GetHashCode() { return(SourceTableName.GetHashCode() ^ SourceConnectionString.GetHashCode() ^ DestinationConnectionString.GetHashCode() ^ BackupType.GetHashCode() ^ CleanupOnly.GetHashCode() ^ DeleteAfterDays.GetHashCode()); }
public IActionResult Create([Bind("BackupTypeID,Name")] BackupType backupType) { if (ModelState.IsValid) { service.Add(backupType); return(RedirectToAction(nameof(Index))); } return(View(backupType)); }
private static string GetBackupTypeText(bool isFullBackup, BackupType backupType) { if (backupType == BackupType.Backup) { return(isFullBackup ? "Full" : "Incremental"); } return(isFullBackup ? "Snapshot" : "Incremental Snapshot"); }
public override void MakePoint(BackupType type, string storagePath) { if (!IsZipValid(storagePath)) { throw new BackupException($"Invalid zip file path: {storagePath}"); } base.MakePoint(type, storagePath); }
private static long GetBackupsSize(Service service, BackupType backupType) { var backups = Backup.GetBackupsForService(service); backups.RemoveAll(x => x.BackupType != backupType); var value = backups.Sum(backup => backup.FileSize); return(value); }
/// <summary> /// Initializes a new instance of the BackupSchedule class. /// </summary> /// <param name="scheduleRecurrence">The schedule recurrence.</param> /// <param name="backupType">The type of backup which needs to be /// taken. Possible values include: 'LocalSnapshot', /// 'CloudSnapshot'</param> /// <param name="retentionCount">The number of backups to be /// retained.</param> /// <param name="startTime">The start time of the schedule.</param> /// <param name="scheduleStatus">The schedule status. Possible values /// include: 'Enabled', 'Disabled'</param> /// <param name="id">The path ID that uniquely identifies the /// object.</param> /// <param name="name">The name of the object.</param> /// <param name="type">The hierarchical type of the object.</param> /// <param name="kind">The Kind of the object. Currently only /// Series8000 is supported. Possible values include: /// 'Series8000'</param> /// <param name="lastSuccessfulRun">The last successful backup run /// which was triggered for the schedule.</param> public BackupSchedule(ScheduleRecurrence scheduleRecurrence, BackupType backupType, long retentionCount, System.DateTime startTime, ScheduleStatus scheduleStatus, string id = default(string), string name = default(string), string type = default(string), Kind?kind = default(Kind?), System.DateTime?lastSuccessfulRun = default(System.DateTime?)) : base(id, name, type, kind) { ScheduleRecurrence = scheduleRecurrence; BackupType = backupType; RetentionCount = retentionCount; StartTime = startTime; ScheduleStatus = scheduleStatus; LastSuccessfulRun = lastSuccessfulRun; }
/// <summary> /// —оздает экземпл¤р класса /// </summary> public BackupCondition() { _backupType = BackupType.None; _backupStorage = String.Empty; _removePreviousBackup = false; _backupStartTime = new DateTime(1, 1, 1, 11, 0, 0, DateTimeKind.Local); _dayOfWeek = 1; _dayOfMonth = 1; }
// Constructor used by AddWork() public Work(string _name, string _src, string _dst, BackupType _backupType, bool _isCrypted) { this.name = _name; this.src = _src; this.dst = _dst; this.backupType = _backupType; this.isCrypted = _isCrypted; this.state = new State(0); this.colorProgressBar = "White"; }
/// <summary> /// Initializes a new instance of the <see cref="BackupRecord"/> class. /// </summary> /// <param name="backupType">Type of the backup.</param> /// <param name="world">The world.</param> /// <param name="citizen">The citizen.</param> /// <param name="label">The label.</param> /// <param name="description">The description.</param> /// <param name="sceneNodes">The scene nodes.</param> public BackupRecord(BackupType backupType, string world, int citizen, string label, string description, SceneNodes sceneNodes) { _world = world; _id = Guid.NewGuid(); _citizen = citizen; _label = label; _description = description; _date = DateTime.Now; SceneNodes = sceneNodes; _backupType = backupType; }
internal static string ToSerializedValue(this BackupType value) { switch (value) { case BackupType.LocalSnapshot: return("LocalSnapshot"); case BackupType.CloudSnapshot: return("CloudSnapshot"); } return(null); }
public Backup() { DateTime = DateTime.Now; if ((DateTime.Hour == 0 && DateTime.Minute == 0) || (DateTime.Hour == 12 && DateTime.Minute == 0)) { Type = BackupType.LongTerm; } else { Type = BackupType.Normal; } }
public BackupJob(string name, BackupType type, string zipPassword, Dictionary <string, object> tags, string targetServer, string targetAccount, string targetCertfile, string exportPath) { Name = name; Type = type; ZipPassword = zipPassword; Tags = tags; TargetServer = targetServer; TargetAccount = targetAccount; TargetCertfile = targetCertfile; ExportPath = exportPath; Zipfile = Path.ChangeExtension(exportPath, ".7z"); }
public ActionResult List(int id, BackupType backupType) { this.EnforceFeaturePermission("FileManager"); var service = Service.GetSelectedService(); var backups = Backup.GetBackupsForService(service, backupType).ToList(); return(Json(backups.Select(x => new { name = x.FileName, value = x.BackupId }), JsonRequestBehavior.AllowGet)); }
private string GetFileName( bool isFullBackup, string backupFolder, string nowAsString, BackupType backupType, out string backupFilePath) { var backupExtension = GetBackupExtension(backupType, isFullBackup); var fileName = isFullBackup ? GetFileNameFor(backupExtension, nowAsString, backupFolder, out backupFilePath, throwWhenFileExists: true) : GetFileNameFor(backupExtension, nowAsString, backupFolder, out backupFilePath); return(fileName); }
public void AddWork(string _name, string _src, string _dst, BackupType _backupType, bool _isCrypted) { try { // Add Work in the program (at the end of the List) this.model.works.Add(new Work(_name, _src, _dst, _backupType, _isCrypted)); this.model.SaveWorks(); } catch { // Return Error Code model.errorMsg?.Invoke("errorAddWork"); } }
/// <summary> /// Set backup input properties /// </summary> /// <param name="input"></param> public void SetBackupInput(BackupInfo input) { this.backupInfo = input; // convert the types this.backupComponent = (BackupComponent)input.BackupComponent; this.backupType = (BackupType)input.BackupType; this.backupDeviceType = (BackupDeviceType)input.BackupDeviceType; if (this.backupRestoreUtil.IsHADRDatabase(this.backupInfo.DatabaseName)) { this.isLocalPrimaryReplica = this.backupRestoreUtil.IsLocalPrimaryReplica(this.backupInfo.DatabaseName); } }
private static string GetFullBackupExtension(BackupType type) { switch (type) { case BackupType.Backup: return(Constants.Documents.PeriodicBackup.FullBackupExtension); case BackupType.Snapshot: return(Constants.Documents.PeriodicBackup.SnapshotExtension); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
public static void CallBackup(BackupType type) { switch (type) { case BackupType.Ambulance: UltimateBackup.API.Functions.callAmbulance(); break; case BackupType.code2: UltimateBackup.API.Functions.callCode2Backup(); break; case BackupType.code3: UltimateBackup.API.Functions.callCode3Backup(); break; case BackupType.felonystop: UltimateBackup.API.Functions.callFelonyStopBackup(); break; case BackupType.female: UltimateBackup.API.Functions.callFemaleBackup(); break; case BackupType.fire: UltimateBackup.API.Functions.callFireDepartment(); break; case BackupType.k9: UltimateBackup.API.Functions.callK9Backup(); break; case BackupType.pursuit: UltimateBackup.API.Functions.callPursuitBackup(); break; case BackupType.roadblock: UltimateBackup.API.Functions.callRoadBlockBackup(); break; case BackupType.spikestrip: UltimateBackup.API.Functions.callSpikeStripsBackup(); break; case BackupType.trafficstop: UltimateBackup.API.Functions.callTrafficStopBackup(); break; } }
public IActionResult Edit(long?id) { if (id == null) { return(NotFound()); } BackupType backupType = service.FindById(id.Value); if (backupType == null) { return(NotFound()); } return(View(backupType)); }
public override void MakePoint(BackupType type, string dirName) { DirectoryInfo directory = new DirectoryInfo(StoragePath); if (!Directory.Exists(Path.Combine(StoragePath, dirName))) { directory = Directory.CreateDirectory(Path.Combine(StoragePath, dirName)); } else { directory = new DirectoryInfo(Path.Combine(StoragePath, dirName)); } base.MakePoint(type, directory.FullName); }
private BackupInfo CreateBackupInfo(string databaseName, BackupType backupType, List <string> backupPathList, Dictionary <string, int> backupPathDevices) { BackupInfo backupInfo = new BackupInfo(); backupInfo.BackupComponent = (int)BackupComponent.Database; backupInfo.BackupDeviceType = (int)BackupDeviceType.Disk; backupInfo.BackupPathDevices = backupPathDevices; backupInfo.BackupPathList = backupPathList; backupInfo.BackupsetName = "default_backup"; backupInfo.BackupType = (int)backupType; backupInfo.DatabaseName = databaseName; backupInfo.SelectedFileGroup = null; backupInfo.SelectedFiles = ""; return(backupInfo); }
public void AddBackupCompressCompletedEntries( BackupType backupType, DateTime compressStarted, DateTime compressEnded, BackupState backupState, ICollection<string> backedupFilePaths, ICollection<string> storagePendingFilesPaths) { if (backedupFilePaths.Count <= 0) throw new ArgumentOutOfRangeException( "backedupFilePaths", backedupFilePaths.Count, "Should be more than zero."); if (storagePendingFilesPaths.Count <= 0) throw new ArgumentOutOfRangeException( "storagePendingFilesPaths", storagePendingFilesPaths.Count, "Should be more than zero."); if (backupState == BackupState.FileCompressSuccess) UpdateBackupLog( backedupFilePaths, backupType == BackupType.Full); lock (_backupHistoryFileLock) { var document = _backupHistoryDocument.Value; if (document.Root == null) throw new Exception("Root element is missing."); document.Root.Add( new BackupHistoryEntry { Id = GetLastBackupHistoryEntryId() + 1, BackupState = backupState, BackupType = backupType, CompressStarted = compressStarted, CompressEnded = compressEnded, NumberOfBackedupFiles = backedupFilePaths.Count, StoragePendingFilesPaths = storagePendingFilesPaths.ToArray() }.ToXElement()); document.Save(_backupHistoryFilePath); InitializeBackupHistoryCache(); } }
private static bool GetDirectoryOrFile(BackupType backupType) { switch (backupType) { case BackupType.ToFolder: case BackupType.Autobackup: if (FolderBrowser.ShowDialog() == DialogResult.OK) { _specifiedFolder = new DirectoryInfo(FolderBrowser.SelectedPath); var path = DirectoryFinder.FormatDisplayPath(_specifiedFolder.FullName); Messenger.Default.Send(new FolderHelper(path)); return true; } break; case BackupType.ToZip: if (SaveFileDialog.ShowDialog() == DialogResult.OK) { _specifiedFile = new FileInfo(SaveFileDialog.FileName); return true; } break; } return false; }
public bool CreateBackupFiles( out BackupType backupType, out List<string> backedupFilePaths, out List<string> storagePendingFilesPaths) { var backupFilePaths = new List<string>(); backedupFilePaths = new List<string>(); storagePendingFilesPaths = new List<string>(); backupType = GetCurrentBackupType(); _log.Info("Starting " + backupType + " backup..."); CreateOrEmptyTempDirectory(); if (!ValidateBackupDirectories(_pathsToBackup)) { RemoveTempDirectory(); return false; } if (!CreateBackupFilesInternal(backupType, backedupFilePaths, backupFilePaths)) { RemoveTempDirectory(); return false; } MoveFilesToStorageDirectory(backupFilePaths, out storagePendingFilesPaths); RemoveTempDirectory(); return true; }
void RunBackup(ObservableCollection<DevicesGroup> driversToBackup, BackupType backupType) { string backupDir = Uri.UnescapeDataString(CfgFile.Get("BackupsFolder")); if (!String.IsNullOrEmpty(backupDir) && new DirectoryInfo(backupDir).Exists) { int driversCount = 0; foreach (DevicesGroup group in driversToBackup) { foreach (DeviceInfo item in group.Devices) { item.SelectedForRestore = true; driverUtils.BackupDriver(item.DeviceName, item.InfName, backupDir); driversCount++; } } if (CurrentDispatcher.Thread != null) { CurrentDispatcher.BeginInvoke((Action)(() => { BackupItems.Add( new BackupItem( backupDir, DateTime.Now, BackupTypes[backupType], driversToBackup ) ); SaveBackupItemsToXML(); BackupFinishTitle = String.Format("{0} " + WPFLocalizeExtensionHelpers.GetUIString("DriversBackupedSuccesfully"), driversCount); BackupStatus = BackupStatus.BackupFinished; })); } } else { if (CurrentDispatcher.Thread != null) { CurrentDispatcher.BeginInvoke((Action)(() => WPFMessageBox.Show(WPFLocalizeExtensionHelpers.GetUIString("CheckBackupsFolder"), WPFLocalizeExtensionHelpers.GetUIString("CheckPreferences"), MessageBoxButton.OK, MessageBoxImage.Error))); } } }
public static void Reset(List<Game> games, BackupType backupType, bool backupEnabled) { if (backupEnabled) { foreach (var game in games) BackupAuto.RemoveFromAutobackup(game); } games.Clear(); }
private void AddFilesToBackup( ZipFile backupFile, BackupType backupType, string pathToBackup, out ICollection<string> backedupFilePaths, out long totalSize) { totalSize = 0; backedupFilePaths = new List<string>(); var backupPathInfo = new DirectoryInfo(pathToBackup); var filesToBackup = backupPathInfo.GetAllFiles().AsEnumerable(); if (backupType == BackupType.Differential) { var latestBackup = _backupHistoryService.GetLatestSuccessfullBackupCompressDate(); if (!latestBackup.HasValue) throw new Exception("Backup history is empty - could not perform differential backup."); filesToBackup = filesToBackup.Where( f => f.LastWriteTime > latestBackup || !_backupHistoryService.IsBackedUp(f.FullName)); } if (_pathsToExclude.Any()) filesToBackup = filesToBackup.Where( f => !_pathsToExclude.Any(e => f.DirectoryName.StartsWith(e)) && !_fileTypesToExclude.Contains(f.Extension.TrimStart('.'))); foreach (var fileToBackup in filesToBackup) { if (fileToBackup.DirectoryName == null) throw new Exception(fileToBackup.FullName + " has no Directory Name."); backupFile.AddFile( fileToBackup.FullName, fileToBackup.DirectoryName.Substring(pathToBackup.Length)); backedupFilePaths.Add(fileToBackup.FullName); totalSize += fileToBackup.Length; _log.Debug( () => string.Format( "Adding file to backup: {0} ({1:N0} bytes).", fileToBackup.FullName, fileToBackup.Length)); } }
//Sets up the param For specific BackupType... private static BackupType[] SetDayParams(BackupType[] array,BackupType valu,int index) { String dat ; if(valu==BackupType.Full) dat = ExtractTagData(fullTag)[index]; else if(valu==BackupType.Incremental) dat = ExtractTagData(incrementalTag)[index]; else if(valu == BackupType.Differential) dat = ExtractTagData(differentialTag)[index]; else dat=String.Empty; if(dat.Length>0) { if(dat.Length>3) { int start = GetDayOfWeekIndex(dat.Substring(0,3)); int end = GetDayOfWeekIndex(dat.Substring(4,dat.Length-4)); for(int x=start;x<end;x++) array[x]=valu; } else { array[GetDayOfWeekIndex(dat)]= valu; } } return array; }
private bool CreateBackupFilesInternal( BackupType backupType, List<string> backedupFilePaths, List<string> backupFilePaths) { for (var i = 0; i < _pathsToBackup.Length; i++) { var pathToBackup = _pathsToBackup[i]; _log.Info("Searching files to backup at \"" + pathToBackup + "\"..."); try { var tempBackupFileName = _tempDirectory + "\\Backup" + (i + 1) + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".zip"; using (var backupFile = new ZipFile(tempBackupFileName, Encoding.UTF8)) { _log.Debug("Adding directory to backup " + pathToBackup + " directory..."); backupFile.Comment = string.Format("Backup of path: {0}.\r\n\r\nCreated by Simple Backup (c).", pathToBackup); backupFile.CompressionMethod = CompressionMethod.BZip2; backupFile.CompressionLevel = CompressionLevel.BestCompression; backupFile.ZipErrorAction = ZipErrorAction.Skip; backupFile.ZipError += BackupFileOnZipError; backupFile.SaveProgress += BackupFileOnSaveProgress; long currentBackupPathTotalFileSize; ICollection<string> currentBackupPathBackedupFilePaths; switch (backupType) { case BackupType.Full: AddFilesToBackup( backupFile, BackupType.Full, pathToBackup, out currentBackupPathBackedupFilePaths, out currentBackupPathTotalFileSize); break; case BackupType.Differential: AddFilesToBackup( backupFile, BackupType.Differential, pathToBackup, out currentBackupPathBackedupFilePaths, out currentBackupPathTotalFileSize); break; default: throw new ArgumentOutOfRangeException("backupType"); } if (currentBackupPathBackedupFilePaths.Count == 0) { _log.Info(string.Format("No files needed to backup for {0}.", pathToBackup)); continue; } backedupFilePaths.AddRange(currentBackupPathBackedupFilePaths); _log.Info( "Compressing " + backupFile.Count + " files (" + currentBackupPathTotalFileSize.ToString("N0") + " bytes)..."); _entriesSavedLogPoint = 0.1f; backupFile.Save(); backupFile.SaveProgress -= BackupFileOnSaveProgress; backupFile.ZipError -= BackupFileOnZipError; backupFilePaths.Add(tempBackupFileName); _log.Info("Compressing completed."); } } catch (Exception e) { _log.Error("Failed to backup " + pathToBackup + ".", e); // TODO: take the "hit" for failed backups return false; } } return true; }
public OptionMessage(OptionsViewModel vm) { HardDrive = vm.SelectedHardDrive; BackupType = vm.BackupType; SpecifiedFolder = vm.SpecifiedFolder; }
//Setups the BackupType according to Data from Text private static BackupType[] SetupDays(int index) { BackupType[] array = new BackupType[7]; array = SetDayParams(array,BackupType.Full,index); array = SetDayParams(array,BackupType.Incremental,index); array = SetDayParams(array,BackupType.Differential,index); return array; }
private void CreateARChive(BackupType type) { if (this.compressor == null) { SevenZipBase.SetLibraryPath(PathHelper.SevenZipLibrary); this.compressor = new SevenZipCompressor(Path.GetTempPath()) { ArchiveFormat = OutArchiveFormat.SevenZip, CompressionLevel = CompressionLevel.Ultra, CompressionMethod = CompressionMethod.Lzma2, CompressionMode = CompressionMode.Create, EventSynchronization = EventSynchronizationStrategy.AlwaysAsynchronous }; this.compressor.Compressing += this.compressor_Compressing; this.compressor.CompressionFinished += this.compressor_CompressionFinished; } var paths = new List<string>(); this._archiveName = Path.Combine(Project.BackupDirectory, String.Format("{0}.7z", Guid.NewGuid())); if (type.HasFlag(BackupType.AllData)) paths.Add(Path.Combine(Project.ProjectFolder, Project.DataDirectory)); else { if (type.HasFlag(BackupType.Scripts)) paths.Add(Path.Combine(Project.ProjectFolder, Project.ScriptsDirectory)); if (type.HasFlag(BackupType.Maps)) { var info = new DirectoryInfo(Project.DataDirectory); paths.AddRange(info.GetFiles("*Map*.arc").Select(file => Path.Combine(Project.ProjectFolder, file.FullName))); } } if (paths.Count == 0) this.compressor_CompressionFinished(null, null); else this.AddToArchive(this._archiveName, paths); Console.WriteLine(String.Join(",\n", paths)); }
public OptionMessage(string hardDrive, BackupType backup, string folder = null) { HardDrive = hardDrive; BackupType = backup; SpecifiedFolder = folder; }
/// <summary> /// Initializes a new instance of the BackupNowRequest class with /// required arguments. /// </summary> public BackupNowRequest(BackupType type) : this() { this.Type = type; }
void RunBackup(ObservableCollection<DevicesGroup> driversToBackup, BackupType backupType) { CreatingBackup = true; string backupDir = Uri.UnescapeDataString(CfgFile.Get("BackupsFolder")); if (!String.IsNullOrEmpty(backupDir) && new DirectoryInfo(backupDir).Exists) { Progress = 0; int driversCount = 0; int totalDriversCount = driversToBackup.Sum(su => su.Devices.Count); foreach (DevicesGroup group in driversToBackup) { group.GroupChecked = true; foreach (DeviceInfo item in group.Devices) { if (driverUtils.BackupDriver(item.DeviceName, item.InfName, backupDir)) { item.SelectedForRestore = true; driversCount++; Progress = driversCount * 100 / totalDriversCount; } } } if (CurrentDispatcher.Thread != null) { CurrentDispatcher.BeginInvoke((Action)(() => { BackupItems.Add( new BackupItem( backupDir, DateTime.Now, BackupTypes[backupType], driversToBackup ) ); SaveBackupItemsToXML(); BackupFinishTitle = String.Format(WPFLocalizeExtensionHelpers.GetUIString("DriversBackupedSuccesfully"), driversCount); BackupStatus = BackupStatus.BackupFinished; CreatingBackup = false; })); } } else { if (CurrentDispatcher.Thread != null) { CurrentDispatcher.BeginInvoke((Action)(() => WPFMessageBox.Show(Application.Current.MainWindow, LocalizeDictionary.Instance.Culture, WPFLocalizeExtensionHelpers.GetUIString("CheckBackupsFolder"), WPFLocalizeExtensionHelpers.GetUIString("CheckPreferences"), WPFMessageBoxButton.OK, MessageBoxImage.Error))); CreatingBackup = false; } } }