public async Task RestoreBackupAsync(BackupMode backupMode = BackupMode.Automatic) { if (backupMode == BackupMode.Automatic && !settingsFacade.IsBackupAutouploadEnabled) { logger.Info("Backup is in Automatic Mode but Auto Backup isn't enabled."); return; } if (!connectivity.IsConnected) { throw new NetworkConnectionException(); } try { BackupRestoreResult result = await DownloadBackupAsync(backupMode); if (result == BackupRestoreResult.NewBackupRestored) { settingsFacade.LastDatabaseUpdate = DateTime.Now; await toastService.ShowToastAsync(Strings.BackupRestoredMessage); messenger.Send(new ReloadMessage()); } } catch (BackupOperationCanceledException ex) { logger.Error(ex, "Operation canceled during restore backup. Execute logout"); await LogoutAsync(); await toastService.ShowToastAsync(Strings.FailedToLoginToBackupMessage, Strings.FailedToLoginToBackupTitle); } }
public static void BackupFile(string _Filename, BackupMode _BackupMode) { if (System.IO.File.Exists(_Filename) == true) { string fileFolder = System.IO.Path.GetDirectoryName(_Filename); if (fileFolder != "") { fileFolder += "\\"; } string backupbackupID = "A" + s_AppStartDate + "B" + DateTime.Now.ToString("yyyy_MM_dd"); string backupToFolder = s_BackupToPath + backupbackupID + "\\"; fileFolder = fileFolder.Replace(s_BackupFromPath, backupToFolder); string backupFileName = ""; if (_BackupMode == BackupMode.Backup_Always_TimeInFilename) { var fileName = System.IO.Path.GetFileNameWithoutExtension(_Filename) + DateTime.Now.ToString(" HH_mm_ss_fff") + Path.GetExtension(_Filename); backupFileName = fileFolder + /*"Backup\\" + backupbackupID + "\\" + */ fileName; backupFileName = ConvertToUniqueFilename(backupFileName, '_'); } else if (_BackupMode == BackupMode.Backup_Daily) { backupFileName = fileFolder + /*"Backup\\" + backupbackupID + "\\" + */ System.IO.Path.GetFileNameWithoutExtension(_Filename) + Path.GetExtension(_Filename); } else { throw new Exception("Unexpected!"); } BackupFile(_Filename, backupFileName); } }
public FASTER_YcsbBenchmark(int threadCount_, int numaStyle_, string distribution_, int readPercent_, int backupOptions_) { // Pin loading thread if it is not used for checkpointing if (kPeriodicCheckpointMilliseconds <= 0) { Native32.AffinitizeThreadShardedNuma(0, 2); } threadCount = threadCount_; numaStyle = numaStyle_; distribution = distribution_; readPercent = readPercent_; this.backupMode = (BackupMode)backupOptions_; #if DASHBOARD statsWritten = new AutoResetEvent[threadCount]; for (int i = 0; i < threadCount; i++) { statsWritten[i] = new AutoResetEvent(false); } threadThroughput = new double[threadCount]; threadAverageLatency = new double[threadCount]; threadMaximumLatency = new double[threadCount]; threadProgress = new long[threadCount]; writeStats = new bool[threadCount]; freq = Stopwatch.Frequency; #endif var path = "D:\\data\\FasterYcsbBenchmark\\"; device = Devices.CreateLogDevice(path + "hlog", preallocateFile: true, useIoCompletionPort: false); // Increase throttle limit for higher concurrency runs if (threadCount > 8) { device.ThrottleLimit *= 2; } if (kSmallMemoryLog) { store = new FasterKV <Key, Value> (kMaxKey / 2, new LogSettings { LogDevice = device, PreallocateLog = true, PageSizeBits = 22, SegmentSizeBits = 26, MemorySizeBits = 26 }, new CheckpointSettings { CheckPointType = CheckpointType.FoldOver, CheckpointDir = path }); } else { store = new FasterKV <Key, Value> (kMaxKey / 2, new LogSettings { LogDevice = device, PreallocateLog = true }, new CheckpointSettings { CheckPointType = CheckpointType.FoldOver, CheckpointDir = path }); } }
public UsbInfo(string backupPath, string volumeLabel, Guid deviceId, BackupMode backupMode, bool backOnCloud, string lastBackup = "Mai", bool canAuto = true) { BackupPath = backupPath; VolumeLabel = volumeLabel; DeviceId = deviceId; LastBackup = lastBackup; this.backupMode = backupMode; BackOnCloud = backOnCloud; CanAutoBackup = canAuto; }
private void rbAuto_CheckedChanged(object sender, EventArgs e) { this.mode = BackupMode.Automatic; label1.Text = "Start time:"; dtpStartDate.Format = DateTimePickerFormat.Time; label2.Visible = false; dtpEndDate.Visible = false; btStartBackup.Enabled = true; btStartBackup.Text = "Start"; }
public BackupDocument() { _backupMode = BackupMode.Secure; _backupMainFolder = string.Empty; _backupTodaysDirectoryPreText = string.Empty; _backupTodaysDirectoryMiddleText = BackupTodaysDirectoryMiddleTextType.YearMonthDay; _backupTodaysDirectoryPostText = string.Empty; _directories = new DirectoryList(); _directories.CollectionChanged += (s, e) => IsDirty = true; }
public static void Save() { string regpath = string.Format(Utils.REG_USRSETTING, Constants.CODELIBRARY); LastOpenedDir = string.IsNullOrEmpty(LastOpenedDir) ? string.Empty : LastOpenedDir; LastOpenedFile = string.IsNullOrEmpty(LastOpenedFile) ? string.Empty : LastOpenedFile; Utils.SetCurrentUserRegisterKey(regpath, Constants.THEME, Theme.ToString()); Utils.SetCurrentUserRegisterKey(regpath, Constants.SORTMODE, SortMode.ToString()); Utils.SetCurrentUserRegisterKey(regpath, Constants.BACKUPMODE, BackupMode.ToString()); Utils.SetCurrentUserRegisterKey(regpath, Constants.LASTOPENEDDIR, LastOpenedDir); Utils.SetCurrentUserRegisterKey(regpath, Constants.LASTOPENEDFILE, LastOpenedFile); Utils.SetCurrentUserRegisterKey(regpath, Constants.BACKUPLOCATION, BackupLocation); Utils.SetCurrentUserRegisterKey(regpath, Constants.OPENDEFAULTONSTART, OpenDefaultOnStart.ToString()); Utils.SetCurrentUserRegisterKey(regpath, Constants.ZOOM, Zoom.ToString()); Utils.SetCurrentUserRegisterKey(regpath, Constants.SPLITTERDISTANCE, SplitterDistance.ToString()); if (string.IsNullOrEmpty(DefaultNoteType)) { DefaultNoteType = string.Empty; } Utils.SetCurrentUserRegisterKey(regpath, Constants.DEFAULT_NOTE_TYPE, DefaultNoteType); Utils.SetCurrentUserRegisterKey(regpath, Constants.PLUGINPATH, PluginPath); if (!Directory.Exists(AppFolder)) { Directory.CreateDirectory(AppFolder); } if (File.Exists(FavoriteFile)) { File.Delete(FavoriteFile); } string _json = Utils.ToJson <List <string> >(FavoriteLibs); File.WriteAllText(FavoriteFile, _json); StyleCollection.Instance.Save(RtfStylesFile); try { VersionNumber _version = new VersionNumber(Assembly.GetEntryAssembly().GetName().Version.ToString()); string _versionString = _version.ToString(); if (string.IsNullOrEmpty(_versionString)) { _versionString = string.Empty; } Utils.SetCurrentUserRegisterKey(regpath, Constants.VERSION, _versionString); } catch { } }
private async Task <BackupRestoreResult> DownloadBackupAsync(BackupMode backupMode) { try { DateTime backupDate = await GetBackupDateAsync(); if (settingsFacade.LastDatabaseUpdate > backupDate && backupMode == BackupMode.Automatic) { logger.Info("Local backup is newer than remote. Don't download backup"); return(BackupRestoreResult.Canceled); } List <string> backups = await cloudBackupService.GetFileNamesAsync(); if (backups.Contains(DatabaseConstants.BACKUP_NAME)) { logger.Info("New backup found. Starting download."); using (Stream backupStream = await cloudBackupService.RestoreAsync(DatabaseConstants.BACKUP_NAME, DatabaseConstants.BACKUP_NAME)) { await fileStore.WriteFileAsync(DatabaseConstants.BACKUP_NAME, backupStream.ReadToEnd()); } logger.Info("Backup downloaded. Replace current file."); bool moveSucceed = await fileStore.TryMoveAsync(DatabaseConstants.BACKUP_NAME, DatabasePathHelper.DbPath, true); if (!moveSucceed) { throw new BackupException("Error Moving downloaded backup file"); } logger.Info("Recreate database context."); contextAdapter.RecreateContext(); return(BackupRestoreResult.NewBackupRestored); } } catch (BackupOperationCanceledException ex) { logger.Error(ex, "Operation canceled during restore backup. Execute logout"); await LogoutAsync(); await toastService.ShowToastAsync(Strings.FailedToLoginToBackupMessage, Strings.FailedToLoginToBackupTitle); } return(BackupRestoreResult.BackupNotFound); }
public async Task UploadBackupAsync(BackupMode backupMode = BackupMode.Automatic) { if (backupMode == BackupMode.Automatic && !settingsFacade.IsBackupAutouploadEnabled) { return; } if (!settingsFacade.IsLoggedInToBackupService) { await LoginAsync(); } await EnqueueBackupTaskAsync(); settingsFacade.LastDatabaseUpdate = DateTime.Now; }
public async Task RestoreBackupAsync(BackupMode backupMode = BackupMode.Automatic) { if (backupMode == BackupMode.Automatic && !settingsFacade.IsBackupAutouploadEnabled) { return; } if (!connectivity.IsConnected) { throw new NetworkConnectionException(); } await DownloadBackupAsync(); settingsFacade.LastDatabaseUpdate = DateTime.Now; settingsFacade.LastExecutionTimeStampSyncBackup = DateTime.Now; }
private void rbManualMode_CheckedChanged(object sender, EventArgs e) { if (bAutoModeRunning == true) //The auto backup is running. { bAutoModeRunning = false; timer1.Stop(); UILog("The automatic backup thread stops."); Log("The automatic backup thread stops. Switch to manual mode."); } this.mode = BackupMode.Manual; label1.Text = "Start date:"; dtpStartDate.Format = DateTimePickerFormat.Short; label2.Visible = true; dtpEndDate.Visible = true; btStartBackup.Enabled = true; btStartBackup.Text = "Upload"; }
public async Task BackupAsync(BackupConfiguration configuration, BackupMode mode) { var watch = new Stopwatch(); watch.Start(); configuration.Validate(); var storageFacade = CreateStorageFacade(configuration.StorageAccount); ILogger logger = new StorageFolderLogger(storageFacade.ChangeFolder("logs")); var cosmosFacade = CreateCosmosFacade(configuration.CosmosAccount, logger); var scheduler = new BackupScheduler( logger, cosmosFacade, storageFacade, configuration.GetCollectionPlans(), configuration.Constants); try { await scheduler.InitializeAsync(); try { if (mode == BackupMode.Iterative) { await scheduler.ProcessIterationAsync(); } else { await scheduler.ProcessContinuouslyAsync(); } logger.Display($"Elapsed Time: {watch.Elapsed}"); logger.Display("Memory used: " + $"{Process.GetCurrentProcess().PrivateMemorySize64 / 1024 / 1024} Mb"); } finally { await Task.WhenAll(scheduler.DisposeAsync(), logger.FlushAsync()); } } catch (Exception ex) { logger.DisplayError(ex); } }
public async Task UploadBackupAsync(BackupMode backupMode = BackupMode.Automatic) { if (backupMode == BackupMode.Automatic && !settingsFacade.IsBackupAutouploadEnabled) { logger.Info("Backup is in Automatic Mode but Auto Backup isn't enabled."); return; } if (!settingsFacade.IsLoggedInToBackupService) { logger.Info("Upload started, but not loggedin. Try to login."); await LoginAsync(); } await EnqueueBackupTaskAsync(); settingsFacade.LastDatabaseUpdate = DateTime.Now; }
public FASTER_YcsbBenchmark(int threadCount_, int numaStyle_, string distribution_, int readPercent_, int backupOptions_) { threadCount = threadCount_; numaStyle = numaStyle_; distribution = distribution_; readPercent = readPercent_; this.backupMode = (BackupMode)backupOptions_; #if DASHBOARD statsWritten = new AutoResetEvent[threadCount]; for (int i = 0; i < threadCount; i++) { statsWritten[i] = new AutoResetEvent(false); } threadThroughput = new double[threadCount]; threadAverageLatency = new double[threadCount]; threadMaximumLatency = new double[threadCount]; threadProgress = new long[threadCount]; writeStats = new bool[threadCount]; freq = Stopwatch.Frequency; #endif var path = "D:\\data\\FasterYcsbBenchmark\\"; device = Devices.CreateLogDevice(path + "hlog", preallocateFile: true); if (kSmallMemoryLog) { store = new FasterKV <Key, Value> (kMaxKey / 2, new LogSettings { LogDevice = device, PreallocateLog = true, PageSizeBits = 22, SegmentSizeBits = 26, MemorySizeBits = 26 }, new CheckpointSettings { CheckPointType = CheckpointType.FoldOver, CheckpointDir = path }); } else { store = new FasterKV <Key, Value> (kMaxKey / 2, new LogSettings { LogDevice = device, PreallocateLog = true }, new CheckpointSettings { CheckPointType = CheckpointType.FoldOver, CheckpointDir = path }); } }
public async Task RestoreBackupAsync(BackupMode backupMode = BackupMode.Automatic) { if (backupMode == BackupMode.Automatic && !settingsFacade.IsBackupAutouploadEnabled) { logger.Info("Backup is in Automatic Mode but Auto Backup isn't enabled."); return; } if (!connectivity.IsConnected) { throw new NetworkConnectionException(); } await DownloadBackupAsync(backupMode); settingsFacade.LastDatabaseUpdate = DateTime.Now; messenger.Send(new ReloadMessage()); }
public async Task RestoreBackupAsync(BackupMode backupMode = BackupMode.Automatic) { if (backupMode == BackupMode.Automatic && !settingsFacade.IsBackupAutouploadEnabled) { logger.Info("Backup is in Automatic Mode but Auto Backup isn't enabled."); return; } if (!connectivity.IsConnected) { throw new NetworkConnectionException(); } var taskId = longRunningTaskRequester.RequestLongRunning(); await DownloadBackupAsync(backupMode); settingsFacade.LastDatabaseUpdate = DateTime.Now; longRunningTaskRequester.EndLongRunning(taskId); }
private async Task <BackupRestoreResult> DownloadBackupAsync(BackupMode backupMode) { DateTime backupDate = await GetBackupDateAsync(); if (settingsFacade.LastDatabaseUpdate > backupDate && backupMode == BackupMode.Automatic) { logger.Info("Local backup is newer than remote. Don't download backup"); return(BackupRestoreResult.Canceled); } List <string> backups = await cloudBackupService.GetFileNamesAsync(); if (backups.Contains(DatabaseConstants.BACKUP_NAME)) { logger.Info("New backup found. Starting download."); using (Stream backupStream = await cloudBackupService.RestoreAsync(DatabaseConstants.BACKUP_NAME, DatabaseConstants.BACKUP_NAME)) { fileStore.WriteFile(DatabaseConstants.BACKUP_NAME, backupStream.ReadToEnd()); } logger.Info("Backup downloaded. Replace current file."); bool moveSucceed = fileStore.TryMove(DatabaseConstants.BACKUP_NAME, DatabasePathHelper.GetDbPath(), true); if (!moveSucceed) { throw new BackupException("Error Moving downloaded backup file"); } logger.Info("Recreate database context."); contextAdapter.RecreateContext(); return(BackupRestoreResult.NewBackupRestored); } return(BackupRestoreResult.BackupNotFound); }
public async Task RestoreBackupAsync(BackupMode backupMode = BackupMode.Automatic) { if (backupMode == BackupMode.Automatic && !settingsFacade.IsBackupAutouploadEnabled) { logger.Info("Backup is in Automatic Mode but Auto Backup isn't enabled."); return; } if (!connectivity.IsConnected) { throw new NetworkConnectionException(); } var result = await DownloadBackupAsync(backupMode); if (result == BackupRestoreResult.NewBackupRestored) { settingsFacade.LastDatabaseUpdate = DateTime.Now; await toastService.ShowToastAsync(Strings.BackupRestoredMessage); messenger.Send(new ReloadMessage()); } }
protected void SetBackupMode() { if (BackupModeMap != null) BackupMode = BackupModeMap(this); }
/// <summary> /// Удалить параметры работы мастера /// </summary> public static void Clear() { databaseConfig = String.Empty; fileStorageDirectory = String.Empty; databaseFile = String.Empty; archveFile = String.Empty; mode = BackupMode.Arhive; }
public async Task <List <BackupInfo> > BackupInfoOrders(BackupMode mode, int codePage) { return(await Task.Run(() => manager.BackupInfoOrders(mode, codePage))); }
public async Task <BackupResult> BackupProjectAsync(DefaultProjectData modProject, string OutputDirectory = "", BackupMode mode = BackupMode.Zip, int totalPercentageAmount = -1) { if (String.IsNullOrWhiteSpace(OutputDirectory)) { OutputDirectory = Path.Combine(Path.GetFullPath(Data.Settings.BackupRootDirectory), modProject.ProjectName); Directory.CreateDirectory(OutputDirectory); } else { OutputDirectory = Path.GetFullPath(OutputDirectory); } string sysFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.Replace("/", "-"); //Log.Here().Important($"System date format: {sysFormat}"); string archiveName = modProject.ProjectName + "_" + DateTime.Now.ToString(sysFormat + "_HH-mm-ss") + ".zip"; string archivePath = Path.Combine(OutputDirectory, archiveName); string gitProjectDirectory = ""; /* * bool gitProjectDetected = false; * * if (!String.IsNullOrEmpty(Data.Settings.GitRootDirectory)) * { * gitProjectDirectory = Path.Combine(Data.Settings.GitRootDirectory, modProject.ProjectName); * if (Directory.Exists(gitProjectDirectory)) * { * gitProjectDirectory = Path.Combine(Data.Settings.GitRootDirectory, modProject.ProjectName); * gitProjectDetected = true; * AppController.Main.UpdateProgressLog("Git repository detected."); * } * } */ if (!modProject.GitGenerated) { AppController.Main.UpdateProgressLog("Creating zip archive from project folders..."); //Log.Here().Activity($"Git project not found. Archiving project {modProject.ProjectName} from project folders directly."); return(await BackupGenerator.CreateArchiveFromDirectory(modProject.Directory, archivePath, true).ConfigureAwait(false)); } else { gitProjectDirectory = Path.Combine(Data.Settings.GitRootDirectory, modProject.ProjectName); if (mode == BackupMode.GitArchive) { AppController.Main.UpdateProgressLog("Running git archive command..."); var success = await GitGenerator.Archive(gitProjectDirectory, archivePath).ConfigureAwait(false); return(success ? BackupResult.Success : BackupResult.Error); } else { AppController.Main.UpdateProgressLog("Creating zip archive..."); return(await BackupGenerator.CreateArchiveFromDirectory(modProject.Directory, archivePath, true).ConfigureAwait(false)); } //Seems to have a problem with junctions and long paths //return BackupGenerator.CreateArchiveFromRepo(gitProjectDirectory, archivePath); } }
/// <summary> /// Copies a directory if it's been updated more recently than the destination equivalent, /// including all files and sub directories. /// </summary> /// <param name="sourceDirectoryPath">The path to the source directory.</param> /// <param name="destinationDirectoryPath">The path to the destination directory.</param> /// <param name="mode">The backup mode</param> /// <param name="loggingBackgroundWorker">A <see cref="LoggingBackgroundWorker"/></param> /// <remarks> /// Based on the example @ https://msdn.microsoft.com/en-us/library/bb762914(v=vs.110).aspx /// </remarks> // ReSharper disable once StyleCop.SA1650 public void CopyIfNewer(string sourceDirectoryPath, string destinationDirectoryPath, BackupMode mode, LoggingBackgroundWorker loggingBackgroundWorker) { // Get the subdirectories for the specified directory. var sourceDirectory = new DirectoryInfo(sourceDirectoryPath); if (!sourceDirectory.Exists) { loggingBackgroundWorker.OnLog(this, new LoggingEventArgs { Message = $"Source directory does not exist or could not be found: {sourceDirectoryPath}" }); } // If the destination directory doesn't exist, create it. if (!Directory.Exists(destinationDirectoryPath)) { Utilities.IO.Directory.CreateDirectory(destinationDirectoryPath); } // Get the files in the directory and copy them to the new location. foreach (var file in sourceDirectory.GetFiles()) { var destinationFilePath = Path.Combine(destinationDirectoryPath, file.Name); var sourceFileInfo = file; if (File.Exists(destinationFilePath)) { var destinationFileInfo = new FileInfo(destinationFilePath); if (sourceFileInfo.LastWriteTime > destinationFileInfo.LastWriteTime) { try { Utilities.IO.File.CopyTo(file.FullName, destinationFilePath); } catch (Exception e) { loggingBackgroundWorker?.OnLog(this, new LoggingEventArgs { Message = $"Exception when trying to copy file from {file.FullName} to {destinationFilePath}.", Exception = e }); } } } else { try { Utilities.IO.File.CopyTo(file.FullName, destinationFilePath); } catch (Exception e) { loggingBackgroundWorker?.OnLog(this, new LoggingEventArgs { Message = $"Exception when trying to copy file from {file.FullName} to {destinationFilePath}.", Exception = e }); } } this.runningObjectCount++; var value = Convert.ToInt32((((this.qtySettingsCompleted * this.totalObjectCount) + this.runningObjectCount) / (SettingsFile.Data.Paths.Count * this.totalObjectCount)) * 100.0); loggingBackgroundWorker?.ReportProgress(value); } if (mode == BackupMode.Synchronise) { // Delete any files on destination directory that aren't in the source directory var destinationDirectory = new DirectoryInfo(destinationDirectoryPath); foreach (var destinationFile in destinationDirectory.GetFiles().Where(df => !sourceDirectory.GetFiles().Any(sf => string.Equals(df.Name, sf.Name)))) { try { // destinationFile.Delete(); Utilities.IO.File.Delete(destinationFile.FullName); } catch (Exception e) { loggingBackgroundWorker?.OnLog(this, new LoggingEventArgs { Message = $"Exception when trying to delete file {destinationFile.FullName}.", Exception = e }); } } // Delete any directories on destination directory that aren't in the source directory foreach (var destinationDir in destinationDirectory.GetDirectories().Where(dd => !sourceDirectory.GetDirectories().Any(sd => string.Equals(dd.Name, sd.Name)))) { try { // destinationDir.Delete(); Utilities.IO.Directory.Delete(destinationDir.FullName); } catch (Exception e) { loggingBackgroundWorker?.OnLog(this, new LoggingEventArgs { Message = $"Exception when trying to delete directory {destinationDir.FullName}.", Exception = e }); } } } // Copy the subdirectories and their contents to new location. foreach (var subdirPath in Directory.GetDirectories(sourceDirectoryPath)) { try { // Path.GetDirectoryName throws PathTooLongException var subdirectoryInfo = new DirectoryInfo(subdirPath); this.CopyIfNewer(subdirPath, Path.Combine(destinationDirectoryPath, subdirectoryInfo.Name), mode, loggingBackgroundWorker); } catch (Exception e) { loggingBackgroundWorker?.OnLog(this, new LoggingEventArgs { Message = $"Exception when trying to copy from {subdirPath} to {destinationDirectoryPath}.", Exception = e }); } this.runningObjectCount++; var value = Convert.ToInt32((((this.qtySettingsCompleted * this.totalObjectCount) + this.runningObjectCount) / (SettingsFile.Data.Paths.Count * this.totalObjectCount)) * 100.0); loggingBackgroundWorker?.ReportProgress(value); } }
public Task BackupAsync(BackupMode backupType) { return(Task.Run(() => Backup(backupType))); }
public void Backup(BackupMode backupType) { if (!package.AppDataFolderExists) { return; } lock (isBusyLock) { Directory.CreateDirectory(Path.GetDirectoryName(BackupPath)); bool exceptionOccured = false; var fastZipEvents = new ICSharpCode.SharpZipLib.Zip.FastZipEvents(); fastZipEvents.FileFailure = (sender, e) => { exceptionOccured = true; e.ContinueRunning = false; }; var zipFile = new ICSharpCode.SharpZipLib.Zip.FastZip(fastZipEvents) { CreateEmptyDirectories = true }; string fileFilter = null; string folderFilter = null; switch (backupType) { case BackupMode.Smart: fileFilter = @";-Settings\\roaming\.lock$;-Settings\\settings\.dat\.LOG[0-9]*$;-ActivationStore\.dat\.LOG[0-9]*$"; folderFilter = @"-AC$;-LocalCache;-TempState"; break; case BackupMode.Full: break; } IsBusy = true; try { zipFile.CreateZip(BackupPath, package.AppDataFolderPath, true, fileFilter, folderFilter); } finally { if (exceptionOccured) { try { File.Delete(BackupPath); } finally { IsBusy = false; throw new InvalidOperationException($"« {package.DisplayName} » must be closed before saving"); } } IsBusy = false; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsBackuped))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(BackupDate))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(State))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Version))); } } }
private void BackupFilePageLocalization(BackupMode mode) { if (mode == BackupMode.Arhive) { this.WizardBackupFilePage.DescriptionText = Strings.BackupFilePage_DescriptionText_ArhiveMode; } else { this.WizardBackupFilePage.DescriptionText = Strings.BackupFilePage_DescriptionText_RestoreMode; } }
/// <summary> /// Save settings into the given file. /// </summary> /// <param name="fileName">file to save settings to</param> /// <param name="syncPathList">list with paths to synchronize</param> public void SaveJob(string fileName, SyncPathList syncPathList) { XmlAttribute attr; XmlElement root; XmlNode node; XmlDocument doc = new XmlDocument(); XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); doc.AppendChild(xmlnode); root = doc.CreateElement("InZync"); // save paths to synchronize node = doc.CreateElement("SourcePaths"); foreach (PathPair pp in syncPathList) { XmlNode pathNode = doc.CreateElement("Path"); attr = doc.CreateAttribute("source"); attr.Value = pp.Source; pathNode.Attributes.Append(attr); attr = doc.CreateAttribute("destination"); attr.Value = pp.Destination; pathNode.Attributes.Append(attr); node.AppendChild(pathNode); } root.AppendChild(node); node = doc.CreateElement("ShowLog"); node.InnerText = ShowLogWindow.ToString(); root.AppendChild(node); node = doc.CreateElement("SaveLog"); node.InnerText = SaveLog.ToString(); root.AppendChild(node); node = doc.CreateElement("AppendLog"); node.InnerText = AppendLog.ToString(); root.AppendChild(node); node = doc.CreateElement("LogFile"); node.InnerText = LogFile; root.AppendChild(node); node = doc.CreateElement("ReadOnly"); node.InnerText = RemoveReadOnlyFlag.ToString(); root.AppendChild(node); node = doc.CreateElement("DirectoriesLikeFiles"); node.InnerText = DirectoriesLikeFiles.ToString(); root.AppendChild(node); node = doc.CreateElement("SubDirectories"); node.InnerText = SubDirectories.ToString(); root.AppendChild(node); node = doc.CreateElement("HiddenFiles"); node.InnerText = ProcessHiddenFiles.ToString(); root.AppendChild(node); node = doc.CreateElement("SystemFiles"); node.InnerText = ProcessSystemFiles.ToString(); root.AppendChild(node); node = doc.CreateElement("TerminateApp"); node.InnerText = TerminateApp.ToString(); root.AppendChild(node); node = doc.CreateElement("RunSilent"); node.InnerText = RunSilent.ToString(); root.AppendChild(node); node = doc.CreateElement("Extensions"); node.InnerText = ExtensionList; root.AppendChild(node); node = doc.CreateElement("ExcludedExtensions"); node.InnerText = ExcludedExtensionList; root.AppendChild(node); node = doc.CreateElement("SourceNewer"); node.InnerText = SourceNewer.ToString(); root.AppendChild(node); node = doc.CreateElement("SourceMissing"); node.InnerText = SourceMissing.ToString(); root.AppendChild(node); node = doc.CreateElement("DestNewer"); node.InnerText = DestNewer.ToString(); root.AppendChild(node); node = doc.CreateElement("DestMissing"); node.InnerText = DestMissing.ToString(); root.AppendChild(node); node = doc.CreateElement("BackupMode"); node.InnerText = BackupMode.ToString(); root.AppendChild(node); node = doc.CreateElement("Template"); node.InnerText = Template.ToString(); root.AppendChild(node); node = doc.CreateElement("ShowOnlyDifferentFiles"); node.InnerText = ShowOnlyDifferentFiles.ToString(); root.AppendChild(node); // save context menu entries node = doc.CreateElement("ContextMenuEntries"); for (int i = 0; i < ContextMenu.Count; i++) { string[] cme = ContextMenu[i].Split('\t'); XmlNode pathNode = doc.CreateElement("ContextMenuEntry"); attr = doc.CreateAttribute("caption"); attr.Value = cme[0]; pathNode.Attributes.Append(attr); attr = doc.CreateAttribute("file"); attr.Value = cme[1]; pathNode.Attributes.Append(attr); if (i == ContextDblClickIdx) { attr = doc.CreateAttribute("DblClick"); //attr.Value = cme[1]; pathNode.Attributes.Append(attr); } node.AppendChild(pathNode); } root.AppendChild(node); doc.AppendChild(root); doc.Save(fileName); }
static void Main(string[] args) { string destination = @"%USERPROFILE%\Documents\DBDBackups\"; string exeLoc = @"C:\Program Files (x86)\Steam\steamapps\common\Dead By Daylight\"; int interval = 600000; int maxBackups = 5; BackupMode backupMode = BackupMode.ON_EXIT; FolderCopy fc; try { XmlDocument config = new XmlDocument(); // Allow for user configuration config.Load("BackupConfig.xml"); XmlNode configRoot = config.SelectSingleNode("config"); if (configRoot["destination"] != null) { destination = configRoot["destination"].InnerText; } if (configRoot["exeLoc"] != null) { exeLoc = configRoot["exeLoc"].InnerText; } if (configRoot["maxBackups"] != null) { maxBackups = Convert.ToInt32(configRoot["maxBackups"].InnerText); } if (configRoot["backupMode"] != null) { backupMode = (BackupMode)(Enum.Parse(typeof(BackupMode), configRoot["backupMode"].InnerText)); } if (configRoot["interval"] != null) { interval = Convert.ToInt32(configRoot["interval"].InnerText) * 60000; } } catch (Exception e) { } fc = new FolderCopy(maxBackups, @"C:\Program Files (x86)\Steam\userdata\81409495\381210\remote\ProfileSaves", destination); Directory.SetCurrentDirectory(exeLoc); Process DBD = new Process(); DBD.StartInfo.FileName = @"DeadByDayLight.exe"; DBD.Start(); DBD.WaitForExit(); Process[] ps = Process.GetProcessesByName("DeadByDaylight-Win64-Shipping"); NonExitCopier nec = null; if (backupMode == BackupMode.INTERVAL) { nec = new IntervalCopier(fc, interval); } else if (backupMode == BackupMode.ON_CHANGE) { nec = new WatcherCopier(fc, @"C:\Program Files (x86)\Steam\userdata\81409495\381210\remote\ProfileSaves\"); } if (nec != null) { nec.start(); } ps[0].WaitForExit(); if (nec != null) { nec.stop(); } fc.CopyFolderContents(); }