/// <summary> /// Creates the display /// </summary> private void MakeList() { this.ContentsToolStripButton.Enabled = false; this.Cursor = Cursors.WaitCursor; this.progressBar.Visible = true; this.progressBar.Style = ProgressBarStyle.Marquee; List<XervBackup.Library.Main.ManifestEntry> Result = null; // Get the list. Background runs task as separate thread, continues to call DoEvents until finished Utility.Tools.Background((Action) delegate() { using (XervBackup.Library.Main.Interface i = new XervBackup.Library.Main.Interface(itsURI, itsOptions)) Result = i.GetBackupSets(); }); // Make the tree this.treeView1.BeginUpdate(); foreach (XervBackup.Library.Main.ManifestEntry M in Result) { TreeNode N = NewNode(M); N.Nodes.AddRange((from XervBackup.Library.Main.ManifestEntry Mi in M.Incrementals select NewNode(Mi)).ToArray()); this.treeView1.Nodes.Add(N); } this.treeView1.Sort(); this.treeView1.EndUpdate(); this.progressBar.Visible = false; this.ContentsToolStripButton.Enabled = true; this.Cursor = Cursors.Default; }
/// <summary> /// Call XervBackup for the restore /// </summary> /// <param name="aSource">Source file</param> /// <param name="aTarget">Place to put it</param> /// <param name="aOptions">XervBackup Options</param> private void Restore(string aSource, string aTarget, Dictionary<string,string> aOptions) { this.ProgressGroupBox.Visible = true; this.ProgressGroupBox.BringToFront(); this.progressBar.Style = ProgressBarStyle.Marquee; this.RestoreToolStripButton.Enabled = false; this.treeView.Enabled = false; string Result = null; Utility.Tools.Background((Action) delegate() { using (XervBackup.Library.Main.Interface i = new XervBackup.Library.Main.Interface(aSource, FixOptions(aOptions))) Result = i.Restore(new string[] { aTarget }); }); MessageBox.Show(Result); this.ProgressGroupBox.Visible = false; this.RestoreToolStripButton.Enabled = true; this.treeView.Enabled = true; }
private void Restore(object sender, DoWorkEventArgs args) { //TODO: add a Try-Catch here Schedule s = m_wrapper.DataConnection.GetObjectById<Schedule>(m_wrapper.ScheduleID); RestoreTask task = new RestoreTask(s, m_wrapper.FullRestorePath, m_wrapper.RestoreFilter, m_wrapper.RestoreTime); Dictionary<string, string> options = new Dictionary<string, string>(); string destination = task.GetConfiguration(options); if (options.ContainsKey("filter")) options.Remove("filter"); using (Library.Main.Interface i = new XervBackup.Library.Main.Interface(destination, options)) { i.OperationProgress += new XervBackup.Library.Main.OperationProgressEvent(i_OperationProgress); i.Restore(task.LocalPath.Split(System.IO.Path.PathSeparator)); } }
private static bool RunBackup(string[] args, XervBackup.Scheduler.Data.HistoryDataSet.HistoryRow aHistoryRow) { // Log the start Library.Logging.Log.WriteMessage(Name + " " + String.Join(" ", args) + (itsDryRun ? " DryRun as" : " as ") + XervBackup.Scheduler.Utility.User.UserName, XervBackup.Library.Logging.LogMessageType.Information); // See if the XML file name was on the command line string XML = (args.Length > 1) ? XML = args[1] : XervBackup.Scheduler.Data.SchedulerDataSet.DefaultPath(); // Convert our options to XervBackup options Options BackupOptions = new Options(Job, XML); // Get disabled monitors DisabledMonitors = BackupOptions.DisabledMonitors; // Complain about any results from the drive mapping if (!string.IsNullOrEmpty(BackupOptions.MapResults)) Library.Logging.Log.WriteMessage(BackupOptions.MapResults, XervBackup.Library.Logging.LogMessageType.Information); // Get the signature file temp XervBackup.Library.Utility.TempFolder SigTemp = new XervBackup.Library.Utility.TempFolder(); string SigThingy = System.IO.Path.Combine(SigTemp, XervBackup.Scheduler.Data.SchedulerDataSet.DefaultName); if (XervBackup.Scheduler.Utility.Tools.NoException((Action)delegate() { System.IO.File.Copy(XervBackup.Scheduler.Data.SchedulerDataSet.DefaultPath(), SigThingy); })) BackupOptions["signature-control-files"] = SigThingy; // See if there is a pipe server listening, if so, connect to it for progress messages bool HasPipe = XervBackup.Scheduler.Utility.NamedPipeServerStream.ServerIsUp( XervBackup.Scheduler.Utility.NamedPipeServerStream.MakePipeName(PipeBaseName, XervBackup.Scheduler.Utility.User.UserName, System.IO.Pipes.PipeDirection.In)); if (HasPipe) Pipe.Connecter(); // Run the dern thing already string Result = "Not started"; bool OK = false; if (itsDryRun) { OK = true; Result = "DryRun"; if(HasPipe) TestProgress(5); // Just send fake progress } else { try { using (XervBackup.Library.Main.Interface i = new XervBackup.Library.Main.Interface(BackupOptions.Target, BackupOptions)) { // Set our events if we have a pipe if (HasPipe) { i.OperationProgress += new XervBackup.Library.Main.OperationProgressEvent(Pipe.OperationProgress); i.OperationCompleted += new XervBackup.Library.Main.OperationProgressEvent(Pipe.OperationProgress); } Result = i.Backup(BackupOptions.Source); } OK = true; } catch (Exception Ex) { // Dang Result = "Error: " + Ex.Message; } } // Log the done. Library.Logging.Log.WriteMessage("Finished: "+(OK?"OK":Result), OK ? XervBackup.Library.Logging.LogMessageType.Information : XervBackup.Library.Logging.LogMessageType.Error); // Put deletions in the log, where they belong. // Deleting backup at 07/06/2011 06:05:21 foreach(string Line in Result.Split('\n')) if (Line.StartsWith("Deleting backup at ")) Library.Logging.Log.WriteMessage(Line, XervBackup.Library.Logging.LogMessageType.Information); // OK, made it, update the history aHistoryRow.Update("Backup", BackupOptions.Full, OK, Result, BackupOptions.Checksum, BackupOptions.CheckMod); LimitLogFiles(BackupOptions.LogFileMaxAgeDays); // zero has no effect. // woot return OK; }