//----------------------------------------------------------------------------- // backup //----------------------------------------------------------------------------- /// <summary> /// Performs the backup operation. The <paramref name="sBackupPath"/> and /// <paramref name="backupClient"/> parameters are mutually exclusive. If /// backupClient is null, then the backup will be created on disk in the /// location specified by sBackupPath. If backupClient is non-null, the /// sBackupPath parameter is ignored. /// </summary> /// <param name="sBackupPath"> /// The full pathname where the backup set is to be created. This parameter /// is ignored if the backupClient parameter is non-null. /// </param> /// <param name="sPassword"> /// Password to be used for the backup. A non-empty password allows the backup /// to be restored on a machine other than the one where the database exists. The /// database's encryption key (if encryption is enabled) will be wrapped in the /// specified password so that the backup can be restored to a different machine. /// </param> /// <param name="backupClient"> /// If non-null, the backupClient is an object the provides interfaces for storing /// backup data to disk, tape, or other media. If null, the backup data is stored /// to a file set specified by the sBackupPath parameter. /// </param> /// <param name="backupStatus"> /// If non-null, the backupStatus object provides an interface that this method /// calls to report backup progress. /// </param> /// <returns> /// Returns a sequence number for this backup. This is for informational /// purposes only. For instance, users can use it to label their backup tapes. /// </returns> public uint backup( string sBackupPath, string sPassword, BackupClient backupClient, BackupStatus backupStatus) { RCODE rc; uint uiSeqNum; BackupClientDelegate backupClientDelegate = null; BackupClientCallback fnBackupClient = null; BackupStatusDelegate backupStatusDelegate = null; BackupStatusCallback fnBackupStatus = null; if (backupClient != null) { backupClientDelegate = new BackupClientDelegate(backupClient); fnBackupClient = new BackupClientCallback(backupClientDelegate.funcBackupClient); } if (backupStatus != null) { backupStatusDelegate = new BackupStatusDelegate(backupStatus); fnBackupStatus = new BackupStatusCallback(backupStatusDelegate.funcBackupStatus); } if ((rc = xflaim_Backup_backup(m_pBackup, sBackupPath, sPassword, out uiSeqNum, fnBackupClient, fnBackupStatus)) != 0) { throw new XFlaimException(rc); } return(uiSeqNum); }
public Backup(int id, DateTime date, BackupStatus status, IEnumerable <TodoItem> items) { _items = items; Status = status; Date = date; Id = id; }
public void BackupFile(string destFolder, string fileToCopy, BackupStatus backupStatus) { IProgress <string> stateProgress = backupStatus.StateProgress as IProgress <string>; string DestFilePath = System.IO.Path.Combine(destFolder, Helpers.ExtractFileFolderNameFromFullPath(fileToCopy)); if (File.Exists(DestFilePath)) { if (CheckIfFileModified(DestFilePath, fileToCopy)) { ReplaceFile(fileToCopy, DestFilePath); stateProgress.Report($"The file {fileToCopy} has been modified, replacing it with new content in {DestFilePath}{Environment.NewLine}"); } else { stateProgress.Report($"The file {fileToCopy} already exists in {DestFilePath}{Environment.NewLine}"); } } else { try { File.Copy(fileToCopy, DestFilePath); stateProgress.Report($"Copying {fileToCopy}{Environment.NewLine}"); } catch (IOException excp) { backupStatus.DialogService.ShowMessageBox(excp.Message); ReportFile.WriteToLog(excp.Message); } }; }
private void SetBackupStatus(BackupStatus backupStatus) { using (var writer = storage.CreateWriter()) { writer.SaveBackupStatus(backupStatus); } }
public void WaitForBackup() { BackupStatus status = null; while (status == null) { Thread.Sleep(100); // Allow the server to process the request status = GetStatusDoc(); } if (NoWait) { Console.WriteLine("Backup operation has started, status is logged at Raven/Backup/Status"); return; } while (status.IsRunning) { Thread.Sleep(1000); status = GetStatusDoc(); } foreach (var msg in status.Messages) { Console.WriteLine("[{0}] {1}", msg.Timestamp, msg.Message); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { BackupStatus s1 = (BackupStatus)value; BackupStatus s2 = (BackupStatus)parameter; return(s1 == s2 ? Visibility.Visible : Visibility.Collapsed); }
public Backup(DateTime date, DateTime executedDate, Guid clientId, string backupPath, BackupStatus status) { Date = date; ExecutedDate = executedDate; ClientId = clientId; BackupPath = backupPath; Status = status; }
internal static string ToSerializedValue(this BackupStatus value) { switch (value) { case BackupStatus.Enabled: return("Enabled"); case BackupStatus.Disabled: return("Disabled"); } return(null); }
public void HandlerEvent(UdpEvent udp_event) { IPEndPoint sender = udp_event.Address; if (udp_event.Message.Type != UdpMessageType.BACKUP_KEEP_ALIVE) { Logger.Warning( string.Format("Receive not keep alive message from {0}, type {1}", sender.Address.ToString(), udp_event.Message.Type)); return; } if (!this.members.Contains(sender.Address.ToString())) { Logger.Warning( string.Format("Receive keep alive message from {0} is not my member.", sender.Address.ToString())); return; } this.last_keep_alive_time = Helper.CurrentTimeMillis(); KeepAliveMessage message = (KeepAliveMessage)udp_event.Message; string ip = sender.Address.ToString(); if (this.status == BackupStatus.INIT && (message.Flag || message.Priority > this.priority)) { this.status = BackupStatus.SLAVER; return; } if (this.status == BackupStatus.MASTER && message.Flag) { if (message.Priority > priority) { this.status = BackupStatus.SLAVER; } else if (message.Priority == priority && this.local_ip.CompareTo(ip) < 0) { this.status = BackupStatus.SLAVER; } } }
public void WaitForBackup() { BackupStatus status = null; var messagesSeenSoFar = new HashSet <BackupStatus.BackupMessage>(); while (status == null) { Thread.Sleep(100); // Allow the server to process the request status = GetStatusDoc(); } if (NoWait) { Console.WriteLine("Backup operation has started, status is logged at Raven/Backup/Status"); return; } while (status.IsRunning) { // Write out the messages as we poll for them, don't wait until the end, this allows "live" updates foreach (var msg in status.Messages) { if (messagesSeenSoFar.Add(msg)) { Console.WriteLine("[{0}] {1}", msg.Timestamp, msg.Message); } } Thread.Sleep(1000); status = GetStatusDoc(); } // After we've know it's finished, write out any remaining messages foreach (var msg in status.Messages) { if (messagesSeenSoFar.Add(msg)) { Console.WriteLine("[{0}] {1}", msg.Timestamp, msg.Message); } } }
/// <summary> /// Backups all the files and folders that in source to dest /// </summary> /// <param name="source"></param> /// <param name="dest"></param> public void Backup(string source, string dest, BackupStatus backupStatus) { try { IProgress <string> stateProgress = backupStatus.StateProgress as IProgress <string>; if (Helpers.CreateDirectoryIfNotExists(dest)) { stateProgress.Report($"Created new folder {dest}"); } foreach (var file in Directory.GetFiles(source)) { BackupFile(dest, file, backupStatus); } foreach (var dir in Directory.GetDirectories(source)) { string fullDirPathInDst = System.IO.Path.Combine(dest, Helpers.ExtractFileFolderNameFromFullPath(dir)); stateProgress.Report($"Backing up {dir} to {fullDirPathInDst}{Environment.NewLine}"); Backup(dir, fullDirPathInDst, backupStatus); stateProgress.Report($"Ended backing up {dir} to {fullDirPathInDst}{Environment.NewLine}"); } if (Directory.GetDirectories(source).Length == 0) { return; } } catch (Exception e) { Directory.Delete(dest); backupStatus.DialogService.ShowMessageBox(e.Message); ReportFile.WriteToLog(e.Message); return; } }
/// <summary> /// Deletes the files that doesn't exist in dest /// </summary> /// <param name="source">The backup folder</param> /// <param name="dest">The folder to backup</param> /// TODO: Change the dest to be source in the parameters public void DeleteFilesFromBackup(string source, string dest, BackupStatus backupStatus) { IProgress <string> stateProgress = backupStatus.StateProgress as IProgress <string>; foreach (var file in Directory.GetFiles(source)) { string fullFilePathInDest = System.IO.Path.Combine(dest, Helpers.ExtractFileFolderNameFromFullPath(file)); if (!File.Exists(fullFilePathInDest)) { stateProgress.Report($"Deleted {file}..."); File.Delete(file); } } foreach (var dir in Directory.GetDirectories(source)) { string fullFilePathInDest = System.IO.Path.Combine(dest, Helpers.ExtractFileFolderNameFromFullPath(dir)); if (!Directory.Exists(fullFilePathInDest)) { stateProgress.Report($"Deleted folder {dir} and all its subfolders and subfiles!"); Directory.Delete(dir, true); } else { DeleteFilesFromBackup(dir, fullFilePathInDest, backupStatus); } } if (Directory.GetDirectories(source).Length == 0) { return; } }
public override BackupStatus GetStatusDoc() { var req = CreateRequest("/docs/" + BackupStatus.RavenFilesystemBackupStatusDocumentKey(parameters.Filesystem), "GET"); try { var json = (RavenJObject)req.ReadResponseJson(); return(json.JsonDeserialization <BackupStatus>()); } catch (WebException ex) { var res = ex.Response as HttpWebResponse; if (res == null) { throw new Exception("Network error"); } if (res.StatusCode == HttpStatusCode.NotFound) { return(null); } } return(null); }
protected void UpdateBackupStatus(string newMsg, BackupStatus.BackupMessageSeverity severity) { try { log.Info(newMsg); var jsonDocument = database.Documents.Get(BackupStatus.RavenBackupStatusDocumentKey, null); if (jsonDocument == null) return; var backupStatus = jsonDocument.DataAsJson.JsonDeserialization<BackupStatus>(); backupStatus.Messages.Add(new BackupStatus.BackupMessage { Message = newMsg, Timestamp = SystemTime.UtcNow, Severity = severity }); database.Documents.Put(BackupStatus.RavenBackupStatusDocumentKey, null, RavenJObject.FromObject(backupStatus), jsonDocument.Metadata, null); } catch (Exception e) { log.WarnException("Failed to update backup status", e); } }
public BackupStatusDelegate( BackupStatus backupStatus) { m_backupStatus = backupStatus; }
public void ChangeStatus(BackupStatus status) { Status = status; }
public void ChannelActivated() { if (this.is_inited) { return; } this.is_inited = true; try { IPAddress address = Dns.GetHostAddresses(Dns.GetHostName()) .FirstOrDefault(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork); this.local_ip = address.ToString(); } catch { Logger.Warning("Get local ip failed."); } foreach (String member in Args.Instance.Node.Backup.Members) { if (!this.local_ip.Equals(member)) { members.Add(member); } } Logger.Info( string.Format("Backup localIp:{0}, members: size= {1}, {2}", this.local_ip, members.Count, members)); this.status = BackupStatus.INIT; this.last_keep_alive_time = Helper.CurrentTimeMillis(); this.service_handler = ScheduledExecutorService.Scheduled(() => { try { if (this.status != BackupStatus.MASTER && Helper.CurrentTimeMillis() - this.last_keep_alive_time > this.keep_alive_timeout) { if (this.status == BackupStatus.SLAVER) { this.status = BackupStatus.INIT; this.last_keep_alive_time = Helper.CurrentTimeMillis(); } else { this.status = BackupStatus.MASTER; } } if (this.status == BackupStatus.SLAVER) { return; } foreach (string member in this.members) { this.message_handler.Accept( new UdpEvent(new KeepAliveMessage(this.status.Equals(BackupStatus.MASTER), priority), new IPEndPoint(IPAddress.Parse(member), port))); } } catch (System.Exception e) { Logger.Error("Exception in send keep alive message : " + e.Message); } }, 1000, 1000); }
//----------------------------------------------------------------------------- // backup //----------------------------------------------------------------------------- /// <summary> /// Performs the backup operation. The <paramref name="sBackupPath"/> and /// <paramref name="backupClient"/> parameters are mutually exclusive. If /// backupClient is null, then the backup will be created on disk in the /// location specified by sBackupPath. If backupClient is non-null, the /// sBackupPath parameter is ignored. /// </summary> /// <param name="sBackupPath"> /// The full pathname where the backup set is to be created. This parameter /// is ignored if the backupClient parameter is non-null. /// </param> /// <param name="sPassword"> /// Password to be used for the backup. A non-empty password allows the backup /// to be restored on a machine other than the one where the database exists. The /// database's encryption key (if encryption is enabled) will be wrapped in the /// specified password so that the backup can be restored to a different machine. /// </param> /// <param name="backupClient"> /// If non-null, the backupClient is an object the provides interfaces for storing /// backup data to disk, tape, or other media. If null, the backup data is stored /// to a file set specified by the sBackupPath parameter. /// </param> /// <param name="backupStatus"> /// If non-null, the backupStatus object provides an interface that this method /// calls to report backup progress. /// </param> /// <returns> /// Returns a sequence number for this backup. This is for informational /// purposes only. For instance, users can use it to label their backup tapes. /// </returns> public uint backup( string sBackupPath, string sPassword, BackupClient backupClient, BackupStatus backupStatus) { RCODE rc; uint uiSeqNum; BackupClientDelegate backupClientDelegate = null; BackupClientCallback fnBackupClient = null; BackupStatusDelegate backupStatusDelegate = null; BackupStatusCallback fnBackupStatus = null; if (backupClient != null) { backupClientDelegate = new BackupClientDelegate( backupClient); fnBackupClient = new BackupClientCallback( backupClientDelegate.funcBackupClient); } if (backupStatus != null) { backupStatusDelegate = new BackupStatusDelegate( backupStatus); fnBackupStatus = new BackupStatusCallback( backupStatusDelegate.funcBackupStatus); } if ((rc = xflaim_Backup_backup( m_pBackup, sBackupPath, sPassword, out uiSeqNum, fnBackupClient, fnBackupStatus)) != 0) { throw new XFlaimException( rc); } return( uiSeqNum); }
public async Task <HttpResponseMessage> Backup() { var backupRequest = await ReadJsonObjectAsync <FilesystemBackupRequest>(); var incrementalString = InnerRequest.RequestUri.ParseQueryString()["incremental"]; bool incrementalBackup; if (bool.TryParse(incrementalString, out incrementalBackup) == false) { incrementalBackup = false; } if (backupRequest.FileSystemDocument == null && FileSystem.Name != null) { var jsonDocument = DatabasesLandlord.SystemDatabase.Documents.Get("Raven/Filesystems/" + FileSystem.Name, null); if (jsonDocument != null) { backupRequest.FileSystemDocument = jsonDocument.DataAsJson.JsonDeserialization <FileSystemDocument>(); backupRequest.FileSystemDocument.Id = FileSystem.Name; } } var transactionalStorage = FileSystem.Storage; var filesystemDocument = backupRequest.FileSystemDocument; var backupDestinationDirectory = backupRequest.BackupLocation; var document = Database.Documents.Get(BackupStatus.RavenFilesystemBackupStatusDocumentKey(FilesystemName), null); if (document != null) { var backupStatus = document.DataAsJson.JsonDeserialization <BackupStatus>(); if (backupStatus.IsRunning) { throw new InvalidOperationException("Backup is already running"); } } bool enableIncrementalBackup; if (incrementalBackup && transactionalStorage is Storage.Esent.TransactionalStorage && (bool.TryParse(Database.Configuration.Settings["Raven/Esent/CircularLog"], out enableIncrementalBackup) == false || enableIncrementalBackup)) { throw new InvalidOperationException("In order to run incremental backups using Esent you must have circular logging disabled"); } if (incrementalBackup && transactionalStorage is Storage.Voron.TransactionalStorage && Database.Configuration.Storage.Voron.AllowIncrementalBackups == false) { throw new InvalidOperationException("In order to run incremental backups using Voron you must have the appropriate setting key (Raven/Voron/AllowIncrementalBackups) set to true"); } Database.Documents.Put(BackupStatus.RavenFilesystemBackupStatusDocumentKey(FilesystemName), null, RavenJObject.FromObject(new BackupStatus { Started = SystemTime.UtcNow, IsRunning = true, }), new RavenJObject(), null); if (filesystemDocument.Settings.ContainsKey("Raven/StorageTypeName") == false) { filesystemDocument.Settings["Raven/StorageTypeName"] = transactionalStorage.FriendlyName ?? transactionalStorage.GetType().AssemblyQualifiedName; } transactionalStorage.StartBackupOperation(DatabasesLandlord.SystemDatabase, FileSystem, backupDestinationDirectory, incrementalBackup, filesystemDocument); return(GetEmptyMessage(HttpStatusCode.Created)); }
private void SetBackupStatus(BackupStatus backupStatus) { filesystem.Storage.Batch(accessor => accessor.SetConfig(BackupStatus.RavenBackupStatusDocumentKey, RavenJObject.FromObject(backupStatus))); }
/// <summary> /// Backing up one folder /// </summary> /// <param name="itemsProgress"></param> /// <returns></returns> public async Task BackupOneDirAsync(string destinationPath, SourceFolder sourceFolder, BackupStatus backupStatus) { string source = sourceFolder.FolderInfo.FullPath; string dest = destinationPath; string folderName = sourceFolder.FolderInfo.Name; IProgress <string> stateProgress = backupStatus.StateProgress as IProgress <string>; IProgress <ProgressionItemsReport> itemsProgress = backupStatus.ItemsProgress as IProgress <ProgressionItemsReport>; if (Helpers.CreateDirectoryIfNotExists(dest)) { stateProgress.Report($"Created new folder {dest}"); } int count = 0; // Handling the top directories foreach (var src in Directory.GetDirectories(source)) { string name = Helpers.ExtractFileFolderNameFromFullPath(src); // Refactor slashes string dst = $"{destinationPath}\\{name}"; stateProgress.Report($"Start backing up {src} to { dst} {Environment.NewLine}"); await Task.Run(() => { Backup(src, dst, backupStatus); }); stateProgress.Report($"End backing up {src} to { dst} {Environment.NewLine}"); count++; itemsProgress.Report(new ProgressionItemsReport { ItemsCompletedCounter = count * 100 / sourceFolder.FolderInfo.ItemsCount, ItemsRemainingCounter = sourceFolder.FolderInfo.ItemsCount - count }); } // Handling the top files foreach (var file in Directory.GetFiles(source)) { BackupFile(dest, file, backupStatus); count++; itemsProgress.Report(new ProgressionItemsReport { ItemsCompletedCounter = count * 100 / sourceFolder.FolderInfo.ItemsCount, ItemsRemainingCounter = sourceFolder.FolderInfo.ItemsCount - count }); } string successMessage = $"Backing up from {source} to {dest} have been completed successfuly!"; stateProgress.Report(successMessage); ReportFile.WriteToLog(successMessage); }
public void ExportTest() { //Export backup //This API will return the content of a specified backup id the CSV format specified below. //Request: GET / exports /{ // backup id} // Request body: N / A //Response body: // ``` // Username;TodoItemId;Subject;DueDate;Done // {username};{todoitemid};{subject};{duedate};{done} // ``` // Arrange BackupStatus backupStatus = BackupStatus.InProgress; var items = new List <TodoItem>(); var date = DateTime.Now; Random random = new Random(); for (int i = 0; i < 2; i++) { date = date.AddDays(i); for (int j = 0; j < 5; j++) { date = date.AddHours(j); var done = random.Next(0, int.MaxValue); items.Add(new TodoItem(i + j, "Sean Williams", string.Format("Subject {0}", i + j), date, Convert.ToBoolean(done))); } } IBackupService backupService = new StubIBackupService() { InitiateAsync = () => { // Generate a random id var generator = new Random(); var id = 0; lock (generator) { id = random.Next(1, int.MaxValue); } return(Task.FromResult(id)); }, GetAll = () => { var rtnVal = new List <Backup.Backup>(); date = DateTime.Now; for (int i = 0; i < 7; i++) { date = date.AddDays(i); for (int j = 0; j < 24; j++) { date = date.AddHours(j); rtnVal.Add(new Backup.Backup(i + j, date, backupStatus, items)); } } return(rtnVal); } }; BackupsController target = new BackupsController(backupService) { Request = new HttpRequestMessage() { Method = HttpMethod.Get, Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } } } }; // Act int backupId = 1; var actual = target.Export(backupId) as ResponseMessageResult; // Assert Assert.IsNotNull(actual); Assert.IsTrue(actual.Response.IsSuccessStatusCode); Assert.IsTrue(0 < actual.Response.Content.Headers.ContentLength); }
public void GetFailedTest() { //List backups //This API will list all backups that have initiated.Backup status is one of the following: //• In progress //• OK //• Failed //Request: GET / backups //Request body: N / A //Response body: // ``` // [ // { // “backupId”: “<backup id>”, // “date”: “<backup date>”, //“status”: “<backup status>” // }, // { // … // } // ] // ``` // Arrange BackupStatus backupStatus = BackupStatus.Failed; IBackupService backupService = new StubIBackupService() { InitiateAsync = () => { // Generate a random id var generator = new Random(); var id = 0; lock (generator) { id = (new Random()).Next(1, int.MaxValue); } return(Task.FromResult(id)); }, GetAll = () => { var rtnVal = new List <Backup.Backup>(); var date = DateTime.Now; for (int i = 0; i < 7; i++) { date = date.AddDays(i); for (int j = 0; j < 24; j++) { date = date.AddHours(j); rtnVal.Add(new Backup.Backup(i + j, date, backupStatus, null)); } } return(rtnVal); } }; BackupsController target = new BackupsController(backupService) { Request = new HttpRequestMessage() { Method = HttpMethod.Get, Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } } } }; // Act var actual = target.Get() as OkNegotiatedContentResult <IEnumerable <BackupViewModel> >; // Assert Assert.IsNotNull(actual); var backups = actual.Content; Assert.IsNotNull(backups); Assert.IsTrue(backups.Any()); Assert.IsTrue(backups.All((b) => 0 <= b.BackupId)); Assert.IsTrue(backups.All((b) => backupStatus == b.Status)); }
protected void WaitForBackup(string fileStoreName, bool checkError) { Func <string, JsonDocument> getDocument = fsName => servers.First().SystemDatabase.Documents.Get(BackupStatus.RavenFilesystemBackupStatusDocumentKey(fsName), null); var done = SpinWait.SpinUntil(() => { // We expect to get the doc from database that we tried to backup var jsonDocument = getDocument(fileStoreName); if (jsonDocument == null) { return(true); } var backupStatus = jsonDocument.DataAsJson.JsonDeserialization <BackupStatus>(); if (backupStatus.IsRunning == false) { if (checkError) { var firstOrDefault = backupStatus.Messages.FirstOrDefault(x => x.Severity == BackupStatus.BackupMessageSeverity.Error); if (firstOrDefault != null) { Assert.True(false, string.Format("{0}\n\nDetails: {1}", firstOrDefault.Message, firstOrDefault.Details)); } } return(true); } return(false); }, Debugger.IsAttached ? TimeSpan.FromMinutes(120) : TimeSpan.FromMinutes(15)); Assert.True(done); }
public async Task Foo() { IFilesStore store = null; #region create_fs_2 await store.AsyncFilesCommands.Admin .CreateFileSystemAsync(new FileSystemDocument { Id = "Raven/FileSystems/NorthwindFS", Settings = { { Constants.FileSystem.DataDirectory, "~/FileSystems/NorthwindFS" }, { Constants.ActiveBundles, "Versioning" } } }, "NorthwindFS"); #endregion #region ensure_fs_exists_2 await store.AsyncFilesCommands.Admin .EnsureFileSystemExistsAsync("NorthwindFS"); #endregion #region delete_fs_2 await store.AsyncFilesCommands.Admin .DeleteFileSystemAsync(hardDelete : true); #endregion #region start_backup_2 await store.AsyncFilesCommands.Admin .StartBackup(@"C:\backups\NorthwindFS", null, false, "NorthwindFS"); #endregion #region start_backup_3 BackupStatus status = await store.AsyncFilesCommands.Configuration .GetKeyAsync <BackupStatus>(BackupStatus.RavenBackupStatusDocumentKey); if (status.IsRunning) { // ... // } #endregion #region start_restore_2 long restoreOperationId = await store.AsyncFilesCommands.Admin .StartRestore(new FilesystemRestoreRequest() { BackupLocation = @"C:\backups\NorthwindFS", FilesystemLocation = @"~\FileSystems\NewNorthwindFS", FilesystemName = "NewNorthwindFS" }); #endregion #region start_restore_3 using (var sysDbStore = new DocumentStore { Url = "http://localhost:8080/" }.Initialize()) { await new Operation((AsyncServerClient)sysDbStore.AsyncDatabaseCommands, restoreOperationId) .WaitForCompletionAsync(); } #endregion #region start_compact_2 long compactOperationId = await store.AsyncFilesCommands.Admin .StartCompact("NorthwindFS"); #endregion #region start_compact_3 using (var sysDbStore = new DocumentStore { Url = "http://localhost:8080/" }.Initialize()) { await new Operation((AsyncServerClient)sysDbStore.AsyncDatabaseCommands, compactOperationId) .WaitForCompletionAsync(); } #endregion #region reset_indexes_2 await store.AsyncFilesCommands.Admin .ResetIndexes("NorthwindFS"); #endregion #region get_names_2 string[] fsNames = await store.AsyncFilesCommands.Admin .GetNamesAsync(); #endregion #region get_stats_2 FileSystemStats[] fsStats = await store.AsyncFilesCommands.Admin .GetStatisticsAsync(); #endregion }
//--- backup ---------------------------- public void Process( Operation operation, Ctrl ctrl, bool debug ) { try { this.ctrl = ctrl; this.debug = debug; this.logging = new BlockingCollection<string>( Maximum_Items_In_Queue ); this.status = new BackupStatus(); this.cancel = new CancellationTokenSource(); pause.Set(); this.start = DateTime.Now; this.queue = new BlockingCollection<UpdateRequest>( Maximum_Items_In_Queue ); this.current = null; this.history = null; this.log = new Thread( new ThreadStart( LogHandler ) ); this.log.Name = "Log"; this.log.Priority = ThreadPriority.BelowNormal; this.log.Start(); switch( operation ) { case Operation.Merge: { this.merge = new Thread( new ThreadStart( MergeHandler ) ); this.merge.Name = "Update"; this.merge.Priority = ThreadPriority.BelowNormal; this.merge.Start(); break; } case Operation.Backup: { this.scan = new Thread( new ThreadStart( ScanHandler ) ); this.scan .Name = "Scan"; this.scan .Priority = ThreadPriority.BelowNormal; this.scan .Start(); this.update = new Thread( new ThreadStart( UpdateHandler ) ); this.update.Name = "Update"; this.update.Priority = ThreadPriority.BelowNormal; this.update.Start(); break; } } } catch( Exception ex ) { Msg( "Process: {0}", Except.ToString( ex, debug ) ); } }