Beispiel #1
0
 // Just pack up a PROGRESS command all ready for the service and send it out stdout.
 // Try to connect to the named pipe server, if not, don't try again for 5 seconds.
 public static void OperationProgress(XervBackup.Library.Main.Interface aCaller, 
     XervBackup.Library.Main.XervBackupOperation aOperation,
     XervBackup.Library.Main.XervBackupOperationMode aSpecificOperation,
     int aProgress, int aSubprogress, string aMessage, string aSubmessage)
 {
     // Progress has come, make sure the pipe is ready
     if (itsPipe != null && itsPipeWriter != null && itsPipe.IsConnected)
     {
         try
         {
             lock (Locker)
             {
                 // Package the event up into a null-terminated list for easy disassembly later
                 itsPipeWriter.WriteLine(string.Join(Separator.ToString(), new string[]
                 {
                     "PROGRESS", Program.Job, aOperation.ToString(), aSpecificOperation.ToString(),
                     aProgress.ToString(), aMessage, aSubprogress.ToString(), aSubmessage
                 }));
             }
         }
         catch (Exception Ex)
         {
             Debug.WriteLine(Ex);
         }
     }
 }
 /// <summary>
 /// Edit Settings
 /// </summary>
 /// <remarks>
 /// Here a global password may be set.  If set, User may use it for backups, or not as User is want.
 /// The bubbles thing is not used now.
 /// </remarks>
 /// <param name="aSettings">Settings to edit</param>
 public SettingsDialog(XervBackup.Scheduler.Data.SchedulerDataSet.SettingsDataTable aSettings)
 {
     InitializeComponent();
     this.Settings = aSettings;
     OriginalXML = XmlFromTable(aSettings);
     this.checkBox1.Checked = this.Settings.UseGlobalPassword;
     this.passwordControl1.CheckMod = this.Settings.Values.CheckMod;
     this.passwordControl1.Checksum = this.Settings.Values.Checksum;
     this.numericUpDown1.Value = (decimal)this.Settings.Values.LogFileAgeDays;
     if (this.Settings.Values.IsShowBubblesNull()) this.Settings.Values.ShowBubbles = true;
     this.BubbleCheckBox.Checked = this.Settings.Values.ShowBubbles;
 }
Beispiel #3
0
 /// <summary>
 /// Set the values
 /// </summary>
 /// <param name="aRow">The job row</param>
 /// <param name="aDetails">Text description of the job trigger</param>
 public void SetSummary(XervBackup.Scheduler.Data.SchedulerDataSet.JobsRow aRow, string aDetails)
 {
     this.nameTextBox.Text = aRow.Name;
     this.DescriptionTextBox.Text = aDetails;
     this.sourceTextBox.Text = aRow.Source;
     this.destinationTextBox.Text = aRow.Destination;
     this.LastModLabel.Text = (aRow.IsLastModNull() || aRow.LastMod == DateTime.MinValue) ? "Never edited" : "Last edited: " + aRow.LastMod.ToString("ddd, dd MMMM yyyy hh:mm tt");
     if (aRow.FullOnly || (aRow.FullRepeatDays == 0 && aRow.FullAfterN == 0)) this.fullRepeatStrTextBox.Text = "Always do full backups";
     else this.fullRepeatStrTextBox.Text = aRow.FullRepeatDays > 0 ? aRow.FullRepeatDays + " days " : aRow.FullAfterN.ToString()+" incrementals";
     this.MaxFullTextBox.Text = aRow.MaxFulls > 0 ? "the last "+aRow.MaxFulls.ToString("N0") : "all" ;
     this.MaxAgeTextBox.Text = aRow.MaxAgeDays > 0 ? aRow.MaxAgeDays.ToString("N0") + " days" : "<no limit>" ;
     this.PassRichTextBox.Text = new string[] { "not password protected.", "protected by local password.", "protected by global password." }[aRow.GetCheckSrc()];
 }
Beispiel #4
0
 /// <summary>
 /// Update History
 /// </summary>
 /// <param name="aLastWrite">Date</param>
 /// <param name="aHistoryTable">XML file name</param>
 public void History(DateTime aLastWrite, XervBackup.Scheduler.Data.HistoryDataSet.HistoryDataTable aHistoryTable)
 {
     DateTime LastUpdate = SQLHistoryDataSet.Latest(SQLHistoryDataSet.EntryKind.Schedule);
     XervBackup.Scheduler.Data.HistoryDataSet.HistoryDataTable Changes = new XervBackup.Scheduler.Data.HistoryDataSet.HistoryDataTable();
     foreach (XervBackup.Scheduler.Data.HistoryDataSet.HistoryRow Row in
         from XervBackup.Scheduler.Data.HistoryDataSet.HistoryRow qR in aHistoryTable
         where qR.ActionDate > LastUpdate
         select qR)
         Changes.ImportRow(Row);
     StringBuilder b = new StringBuilder();
     Changes.WriteXml(new System.IO.StringWriter(b));
     SQLHistoryDataSet.Update(XervBackup.Scheduler.Utility.User.UserName, Environment.MachineName, SQLHistoryDataSet.EntryKind.History,
         aLastWrite, b.ToString());
 }
Beispiel #5
0
 /// <summary>
 /// Edit a Job
 /// </summary>
 /// <param name="aRow">Row to edit</param>
 public JobDialog(XervBackup.Scheduler.Data.SchedulerDataSet.JobsRow aRow)
 {
     InitializeComponent();
     if (!string.IsNullOrEmpty(Properties.Settings.Default.TreeViewState))
         this.folderSelectControl1.State = Properties.Settings.Default.TreeViewState;
     this.Text = "Edit job " + aRow.Name + "(" + Utility.User.UserName + ")";
     // Dang background colors in tab pages - can't trust them.
     foreach (TabPage P in this.MainTabControl.TabPages)
         P.BackColor = this.BackColor;
     foreach (TabPage P in this.SourceTabControl.TabPages)
         P.BackColor = this.BackColor;
     this.folderSelectControl1.BackColor = this.BackColor;
     // Add radio buttons for backends; put the backend in the tag
     this.BackEndTableLayoutPanel.Controls.AddRange(
         (from Library.Interface.IBackend qB in XervBackup.Library.DynamicLoader.BackendLoader.Backends
          orderby qB.DisplayName
          select BackendRadioButton(qB)).ToArray());
     // Put the tooltip text at the bottom of the screen for easy user viewage
     this.ExplainToolStripLabel.Text = this.MainTabControl.SelectedTab.ToolTipText;
     // And use the row
     SetRow(aRow);
 }
Beispiel #6
0
 /// <summary>
 /// Enumerates all files and folders in the snapshot
 /// </summary>
 /// <param name="callback">The callback to invoke with each found path</param>
 public void EnumerateFilesAndFolders(XervBackup.Library.Utility.Utility.EnumerationCallbackDelegate callback)
 {
     foreach (string s in m_sourcefolders)
         Utility.Utility.EnumerateFileSystemEntries(s, callback, this.ListFolders, this.ListFiles, this.GetAttributes);
 }
Beispiel #7
0
        /// <summary>
        /// Save the database
        /// </summary>
        /// <param name="aRow">Altered row</param>
        private void Save(XervBackup.Scheduler.Data.SchedulerDataSet.JobsRow aRow)
        {
            if (aRow == null) return; //
            aRow.LastMod = DateTime.Now;
            // Update the drive table
            System.Collections.Generic.Dictionary<string, string> DriveMap = new System.Collections.Generic.Dictionary<string, string>();
            foreach (System.IO.DriveInfo di in System.IO.DriveInfo.GetDrives())
                if ((di.IsReady && di.DriveType == System.IO.DriveType.Network))
                    DriveMap.Add(di.Name[0].ToString(), Utility.Tools.DriveToUNC(di.Name[0]));
            aRow.SetDriveMaps(DriveMap);

            Exception Ex = this.SchedulerDataSet.Save();
            if (Ex != null)
                MessageBox.Show("Can not save schedule: " + Ex.Message);
        }
Beispiel #8
0
 /// <summary>
 /// Adds a new job to the task scheduler
 /// </summary>
 /// <param name="aRow">Job to add</param>
 /// <param name="aTrigger">Trigger to add</param>
 /// <returns>True if all went well</returns>
 private bool NewTask(XervBackup.Scheduler.Data.SchedulerDataSet.JobsRow aRow, Microsoft.Win32.TaskScheduler.Trigger aTrigger)
 {
     // DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
     if (this.toolStripButton2.Checked && aTrigger is Microsoft.Win32.TaskScheduler.TimeTrigger)
     {
         ((Microsoft.Win32.TaskScheduler.TimeTrigger)aTrigger).Repetition.Interval = TimeSpan.FromMinutes(5);
         ((Microsoft.Win32.TaskScheduler.TimeTrigger)aTrigger).Repetition.Duration = TimeSpan.FromDays(1);
     }
     // Used for password
     System.Security.SecureString ss = null;
     bool Result = false;
     do
     {
         DialogResult dr = DialogResult.None;
         // Get the user credentials from the user
         Result = Utility.Tools.NoException((Action)delegate()
         {
             dr = TaskScheduler.InvokeCredentialDialog(this, aRow.TaskName,
                 "Enter user account information for running this backup:", Utility.User.UserName, out ss);
         });
         // If there was an error or user pressed Cancel, bail.
         if (!Result || dr != DialogResult.OK) return false;
         // Send the Trigger to the task scheduler
         Result = Utility.Tools.NoException((Action)delegate()
         {
             TaskScheduler.CreateOrUpdateTask(aRow.TaskName,
                 System.IO.Path.Combine(Application.StartupPath, "XervBackup.Scheduler.RunBackup.exe"),
                 "XervBackup backup task", Utility.User.UserName, ss, aTrigger,
                 "\"" + aRow.Name + "\" \"" + XervBackup.Scheduler.Data.SchedulerDataSet.DefaultPath() + "\"");
         });
         // Assume any error is a security thing and make user enter password again.
         if (!Result && MessageBox.Show("Logon information is not valid for " + Utility.User.UserName + ", [OK] to try again?",
             "Wrong", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) return false;
     } while (!Result);
     return Result; // gonna be true
 }
Beispiel #9
0
        void Runner_XervBackupProgress(XervBackup.Library.Main.XervBackupOperation operation, XervBackupRunner.RunnerState state, string message, string submessage, int progress, int subprogress)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new XervBackupRunner.ProgressEventDelegate(Runner_XervBackupProgress), operation, state, message, submessage, progress, subprogress);
                return;
            }

            string name = "";

            //Dirty read of the instance variable
            try { name = Program.WorkThread.CurrentTask.Schedule.Name; }
            catch { }

            Datamodel.ApplicationSettings.NotificationLevel level;
            try { level = m_settings.BallonNotificationLevel; }
            catch
            {
                m_settings = new Datamodel.ApplicationSettings(Program.DataConnection);
                try { level = m_settings.BallonNotificationLevel; }
                catch
                {
                    //TODO: Should find the cause for this, but at least we do not crash the process
                    return;
                }
            }

            if (state == XervBackupRunner.RunnerState.Started && (level == XervBackup.Datamodel.ApplicationSettings.NotificationLevel.StartAndStop || level == XervBackup.Datamodel.ApplicationSettings.NotificationLevel.Start || level == XervBackup.Datamodel.ApplicationSettings.NotificationLevel.Continous))
            {
                //Show start balloon
                m_trayIcon.ShowBalloonTip(BALLOON_SHOW_TIME, Application.ProductName, String.Format(Strings.MainForm.BalloonTip_Started, name), ToolTipIcon.Info);
            }
            else if (state == XervBackupRunner.RunnerState.Stopped && (level == XervBackup.Datamodel.ApplicationSettings.NotificationLevel.StartAndStop || level == XervBackup.Datamodel.ApplicationSettings.NotificationLevel.Continous))
            {
                //Show stop balloon
                m_trayIcon.ShowBalloonTip(BALLOON_SHOW_TIME, Application.ProductName, String.Format(Strings.MainForm.BalloonTip_Stopped, name), ToolTipIcon.Info);
            }
            else if (state == XervBackupRunner.RunnerState.Running && level == XervBackup.Datamodel.ApplicationSettings.NotificationLevel.Continous)
            {
                //Show update balloon
                m_trayIcon.ShowBalloonTip(BALLOON_SHOW_TIME, Application.ProductName, String.Format(Strings.MainForm.BalloonTip_Running, message), ToolTipIcon.Info);

            }
        }
Beispiel #10
0
 /// <summary>
 /// Enumerates all files and folders in the snapshot
 /// </summary>
 /// <param name="filter">The filter to apply when evaluating files and folders</param>
 /// <param name="callback">The callback to invoke with each found path</param>
 public void EnumerateFilesAndFolders(XervBackup.Library.Utility.Utility.EnumerationCallbackDelegate callback)
 {
     foreach (KeyValuePair<string, SnapShot> s in m_entries)
         Utility.Utility.EnumerateFileSystemEntries(s.Key, callback, this.ListFolders, this.ListFiles);
 }
Beispiel #11
0
 private static string PrintArgSimple(XervBackup.Library.Interface.ICommandLineArgument arg, string name)
 {
     if (string.IsNullOrEmpty(arg.DefaultValue))
         return string.Format("  --{0}{1}    {2}", name, Environment.NewLine, arg.LongDescription);
     else
         return string.Format("  --{0} = {1}{2}    {3}", name, arg.DefaultValue, Environment.NewLine, arg.LongDescription);
 }
Beispiel #12
0
        /// <summary>
        /// Helper method to search a signature file for existence of a specified file
        /// </summary>
        /// <param name="mfi">The manifest that the signature file derives from</param>
        /// <param name="fileToFind">The files to find</param>
        /// <param name="signature">The signature file</param>
        internal static void ContainsFile(Manifestfile mfi, string[] filesToFind, XervBackup.Library.Interface.ICompression signature)
        {
            string[] prefixes = new string[] {
                Utility.Utility.AppendDirSeparator(COMBINED_SIGNATURE_ROOT),
                Utility.Utility.AppendDirSeparator(CONTENT_SIGNATURE_ROOT),
                Utility.Utility.AppendDirSeparator(DELTA_SIGNATURE_ROOT)
            };

            foreach (string prefix in prefixes)
                foreach (string f in FilenamesFromPlatformIndependant(signature.ListFiles(prefix)))
                {
                    string fname = f.Substring(prefix.Length);
                    for (int i = 0; i < filesToFind.Length; i++)
                    {
                        if (string.IsNullOrEmpty(filesToFind[i]))
                            continue;
                        string fileToFind = filesToFind[i];
                        string name = System.IO.Path.IsPathRooted(fileToFind) ? GetRelativeName(mfi.SourceDirs, fileToFind) : fileToFind;
                        if (fname.Equals(name, Utility.Utility.ClientFilenameStringComparision))
                            filesToFind[i] = null;
                    }
                }
        }
 void i_OperationProgress(XervBackup.Library.Main.Interface caller, XervBackup.Library.Main.XervBackupOperation operation, XervBackup.Library.Main.XervBackupOperationMode specificmode, int progress, int subprogress, string message, string submessage)
 {
     m_waitdlg.SetTitle(message);
     m_waitdlg.SetProgress(progress);
 }
Beispiel #14
0
 /// <summary>
 /// XervBackup style progress
 /// </summary>
 private void OperationProgress(XervBackup.Library.Main.Interface aCaller, XervBackup.Library.Main.XervBackupOperation aOperation, XervBackup.Library.Main.XervBackupOperationMode aSpecificOperation, int aProgress, int aSubprogress, string aMessage, string aSubmessage)
 {
     this.BeginInvoke((Action)delegate()
     {
         if (aProgress < 0)
         {
             this.progressBar.Style = ProgressBarStyle.Marquee;
         }
         else
         {
             this.progressBar.Style = ProgressBarStyle.Continuous;
             this.progressBar.Value = Math.Min(this.progressBar.Maximum, aProgress);
         }
         this.MessageTextBox.Text = aMessage + ":" + aSubmessage;
         this.ProgressGroupBox.Update();
     });
 }
Beispiel #15
0
        /// <summary>
        /// Set up the controls for a job row
        /// </summary>
        /// <param name="aRow">Row to use</param>
        private void SetRow(XervBackup.Scheduler.Data.SchedulerDataSet.JobsRow aRow)
        {
            this.Row = aRow;
            this.OriginalXML = RowtoXml(aRow);
            this.Text = "Job: "+ Row.Name;
            // Set the source tree contents
            if (!Row.IsSourceNull())
                this.folderSelectControl1.SelectedFolders = Row.Source.Split(new char[] { System.IO.Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
            if (Row.IsFullRepeatDaysNull()) Row.FullRepeatDays = 10;
            // Full of it.
            this.FullAlwaysRadioButton.Checked = (Row.IsFullOnlyNull() ? false : Row.FullOnly) || (Row.FullAfterN == 0 && Row.FullRepeatDays == 0);
            this.FullDaysNumericUpDown.Value = (decimal)Row.FullRepeatDays;
            this.FullDaysRadioButton.Checked = Row.FullRepeatDays > 0;
            this.FullAfterNNumericUpDown.Value = (decimal)Row.FullAfterN;
            this.FullAfterNRadioButton.Checked = Row.FullAfterN > 0;
            if (!Row.IsFilterNull()) this.FilterList = Row.FilterLines;
            if (!Row.IsMaxFullsNull()) this.MaxFullsNumericUpDown.Value = Row.MaxFulls;
            if (Row.IsMaxAgeDaysNull()) Row.MaxAgeDays = 0;
            this.MaxAgeCheckBox.Checked = Row.MaxAgeDays > 0;
            this.MaxAgeNnumericUpDown.Value = (decimal)Row.MaxAgeDays;
            if (Row.IsMaxFullsNull()) Row.MaxFulls = 4;
            this.MaxFullsCheckBox.Checked = Row.MaxFulls > 0;
            this.MaxFullsNumericUpDown.Value = (decimal)Row.MaxFulls;
            this.PasswordMethodComboBox.SelectedIndex = Row.GetCheckSrc();

            itsAdvanced.Map = Row.MapDrives;
            itsAdvanced.AutoDelete = Row.AutoCleanup;
            this.passwordControl1.CheckMod = aRow.CheckMod;
            this.passwordControl1.Checksum = aRow.Checksum;
            if (Settings.Values.IsCheckSrcNull()) Settings.Values.CheckSrc = false;
            if (!Settings.Values.CheckSrc) this.PasswordMethodComboBox.Items.RemoveAt(2); // No global option if not set
            if (!Row.IsDestinationNull())
            {
                foreach (Control C in this.BackEndTableLayoutPanel.Controls)
                    ((RadioButton)C).Checked = Row.Destination.StartsWith(((XervBackup.Library.Interface.IBackend)C.Tag).ProtocolKey);
            }
        }
Beispiel #16
0
 /// <summary>
 /// Populate a JobsRow with results from the controls
 /// </summary>
 /// <param name="aRow">Row to fill</param>
 private void GetRow(XervBackup.Scheduler.Data.SchedulerDataSet.JobsRow aRow)
 {
     // Now, if User has been in the Destination tab, we may have a new
     // set of destination and options, fetch them.
     if (GuiControl != null && VisitedDestination)
     {
         Dictionary<string, string> Opts = new Dictionary<string, string>();
         Dictionary<string, string> GuiOpts = new Dictionary<string, string>();
         string Dest = string.Empty;
         if (GetConfiguration(out Opts, out GuiOpts, out Dest))
         {
             aRow.SetOptions(Opts);
             aRow.SetGuiOptions(GuiOpts);
             aRow.Destination = Dest;
         }
     }
     // Get stuff from the controls
     aRow.Source = string.Join(System.IO.Path.PathSeparator.ToString(), this.folderSelectControl1.SelectedFolders);
     aRow.FullOnly = this.FullAlwaysRadioButton.Checked;
     aRow.FullAfterN = this.FullAfterNRadioButton.Checked ? (int)this.FullAfterNNumericUpDown.Value : 0;
     aRow.FullRepeatDays = this.FullDaysRadioButton.Checked ? (int)this.FullDaysNumericUpDown.Value : 0;
     aRow.FilterLines = this.FilterList;
     aRow.MaxFulls = this.MaxFullsCheckBox.Checked ? (int)this.MaxFullsNumericUpDown.Value : 0;
     aRow.MaxAgeDays = this.MaxAgeCheckBox.Checked ? (int)this.MaxAgeNnumericUpDown.Value : 0;
     aRow.Enabled = this.TaskEditor.GetTrigger().Enabled;
     aRow.TriggerXML = TaskEditControl.TriggerToXml(this.TaskEditor.GetTrigger());
     if (itsAdvanced.DialogResult == DialogResult.OK)
     {
         aRow.AutoCleanup = itsAdvanced.AutoDelete;
         aRow.MapDrives = itsAdvanced.Map;
     }
     aRow.Checksum = Settings.Values.Checksum;
     aRow.CheckMod = Settings.Values.CheckMod;
     aRow.SetCheckSrc(this.PasswordMethodComboBox.SelectedIndex);
     // Never edited (?)
     if (aRow.IsLastModNull()) aRow.LastMod = DateTime.Now;
 }
Beispiel #17
0
 /// <summary>
 /// Returns the XML of a jobs row
 /// </summary>
 /// <param name="aRow">Row to convert</param>
 /// <returns>XML text in byte array</returns>
 private static byte[] RowtoXml(XervBackup.Scheduler.Data.SchedulerDataSet.JobsRow aRow)
 {
     byte[] Result = null;
     using (XervBackup.Scheduler.Data.SchedulerDataSet.JobsDataTable cTable = new Data.SchedulerDataSet.JobsDataTable())
     {
         cTable.Rows.Add(aRow.ItemArray);
         using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
         {
             cTable.WriteXml(ms);
             Result = ms.ToArray();
         }
     }
     return Result;
 }
Beispiel #18
0
        /// <summary>
        /// Enumerates all files and folders in the snapshot
        /// </summary>
        /// <param name="startpath">The path from which to retrieve files and folders</param>
        /// <param name="callback">The callback to invoke with each found path</param>
        public void EnumerateFilesAndFolders(string startpath, XervBackup.Library.Utility.Utility.EnumerationCallbackDelegate callback)
        {
            foreach (string s in m_sourcefolders)
                if (s.Equals(startpath, Utility.Utility.ClientFilenameStringComparision))
                {
                    Utility.Utility.EnumerateFileSystemEntries(s, callback, this.ListFolders, this.ListFiles, this.GetAttributes);
                    return;
                }

            throw new InvalidOperationException(string.Format(Strings.Shared.InvalidEnumPathError, startpath));
        }
Beispiel #19
0
 private static void PrintEncryptionModule(XervBackup.Library.Interface.IEncryption mod, List<string> lines)
 {
     lines.Add(mod.DisplayName + " (." + mod.FilenameExtension + "):");
     lines.Add(" " + mod.Description);
     if (mod.SupportedCommands != null && mod.SupportedCommands.Count > 0)
     {
         lines.Add(" " + Strings.Program.SupportedOptionsHeader);
         foreach (Library.Interface.ICommandLineArgument arg in mod.SupportedCommands)
             Library.Interface.CommandLineArgument.PrintArgument(lines, arg, "  ");
     }
     lines.Add("");
 }
        public BackupEntryBase ParseFilename(XervBackup.Library.Interface.IFileEntry fe)
        {
            bool oldFilename = false;
            Match m = m_filenameRegExp.Match(fe.Name);
            if (!m.Success)
                m = m_shortRegExp.Match(fe.Name);
            if (!m.Success)
            {
                m = m_oldFilenameRegExp.Match(fe.Name);
                oldFilename = true;
            }
            if (!m.Success)
            {
                m = m_verificationRegExp.Match(fe.Name);
                if (m.Success && m.Value == fe.Name)
                {
                    DateTime verificationtime = DateTime.ParseExact(m.Groups["time"].Value, TIMESTAMP_FORMAT, System.Globalization.CultureInfo.InvariantCulture).ToLocalTime();
                    return new VerificationEntry(fe.Name, fe, verificationtime, m.Groups["time"].Value);
                }

                m = m_deleteTransactionRegExp.Match(fe.Name);
                if (m.Success && m.Value == fe.Name)
                {
                    return new DeleteTransactionEntry(fe, m.Groups["encryption"].Value);
                }
            }

            if (!m.Success)
                return null;
            if (m.Value != fe.Name)
                return null; //Accept only full matches

            bool isFull = m.Groups["inc"].Value == FULL || m.Groups["inc"].Value == FULL_SHORT;
            bool isShortName = m.Groups["inc"].Value.Length == 1;
            string timeString = m.Groups["time"].Value;
            DateTime time;
            if (isShortName)
                time = new DateTime(long.Parse(timeString, System.Globalization.NumberStyles.HexNumber) * TimeSpan.TicksPerSecond, DateTimeKind.Utc).ToLocalTime();
            else
            {
                if (oldFilename)
                    time = DateTime.Parse(timeString.Replace(m.Groups["timeseparator"].Value, ":"));
                else
                    time = DateTime.ParseExact(timeString, TIMESTAMP_FORMAT, System.Globalization.CultureInfo.InvariantCulture).ToLocalTime();
            }

            string extension = m.Groups["extension"].Value;

            int volNumber = -1;
            if (m.Groups["volumenumber"].Success)
                volNumber = int.Parse(m.Groups["volumenumber"].Value);
            else if (m.Groups["extension"].Success && m.Groups["extension"].Value.StartsWith(VOLUME))
            {
                //The extension must be present, but the volumenumber is optional, so the greedy regexp takes it
                if (!int.TryParse(m.Groups["extension"].Value.Substring(VOLUME.Length), out volNumber))
                    volNumber = -1;
            }

            string compression = extension;
            string encryption = null;

            int dotIndex = compression.IndexOf(".");
            if (dotIndex > 0)
            {
                encryption = compression.Substring(dotIndex + 1);
                compression = compression.Substring(0, dotIndex);
            }

            if (Array.IndexOf<string>(new string[] { MANIFEST_OLD , MANIFEST_OLD_SHORT ,MANIFEST_A , MANIFEST_A_SHORT, MANIFEST_B, MANIFEST_B_SHORT },  m.Groups["type"].Value) >= 0)
                return new ManifestEntry(fe.Name, fe, time, isFull, timeString, encryption, m.Groups["type"].Value != MANIFEST_B && m.Groups["type"].Value != MANIFEST_B_SHORT);
            else if (m.Groups["type"].Value == SIGNATURE || m.Groups["type"].Value == SIGNATURE_SHORT)
                return new SignatureEntry(fe.Name, fe, time, isFull, timeString, encryption, compression, volNumber);
            else if (m.Groups["type"].Value == CONTENT || m.Groups["type"].Value == CONTENT_SHORT)
                return new ContentEntry(fe.Name, fe, time, isFull, timeString, encryption, compression, volNumber);
            else
                return null;
        }
Beispiel #21
0
 private string XmlFromTable(XervBackup.Scheduler.Data.SchedulerDataSet.SettingsDataTable aSettings)
 {
     System.IO.MemoryStream ms = new System.IO.MemoryStream();
     aSettings.WriteXml(ms);
     return System.Text.ASCIIEncoding.ASCII.GetString(ms.ToArray());
 }
Beispiel #22
0
        void Runner_XervBackupProgress(XervBackup.Library.Main.XervBackupOperation operation, XervBackupRunner.RunnerState state, string message, string submessage, int progress, int subprogress)
        {
            if (this.InvokeRequired)
                this.Invoke(new XervBackupRunner.ProgressEventDelegate(Runner_XervBackupProgress), operation, state, message, submessage, progress, subprogress);
            else
            {
                WorkProgressbar.Visible = ProgressMessage.Visible = state != XervBackupRunner.RunnerState.Stopped;
                WorkProgressbar.Style = progress < 0 ? ProgressBarStyle.Marquee : ProgressBarStyle.Blocks;
                WorkProgressbar.Value = Math.Max(Math.Min(WorkProgressbar.Maximum, progress), WorkProgressbar.Minimum);
                ProgressMessage.Text = message;
                toolTip1.SetToolTip(SubProgressBar, submessage);

                SubProgressBar.Value = Math.Max(Math.Min(SubProgressBar.Maximum, subprogress), SubProgressBar.Minimum);
                if (!SubProgressBar.Visible && subprogress >= 0)
                    ProgressMessage_TextChanged(null, null);
                SubProgressBar.Visible = subprogress >= 0;

                toolTip1.SetToolTip(ProgressMessage, ProgressMessage.Text);
                toolTip1.SetToolTip(WorkProgressbar, ProgressMessage.Text);
            }
        }
Beispiel #23
0
        /// <summary>
        /// Helper function to support the XervBackup enumeration callback system
        /// </summary>
        /// <param name="rootpath">The root path to look in and use as filter base</param>
        /// <param name="callback">The callback function that collects the output</param>
        public void EnumerateFilesAndFolders(string rootpath, XervBackup.Library.Utility.Utility.EnumerationCallbackDelegate callback)
        {
            //Under normal enumeration, the filter will prevent visiting subfolders for excluded folders
            //But when using USN all files/folders are present in the list, so we have to maintain
            // a list of subfolders that are excluded from the set
            System.Text.StringBuilder local_filter = new StringBuilder();
            System.Text.RegularExpressions.Regex excludedFolders = null;

            foreach (KeyValuePair<string, Win32USN.USN_RECORD> r in this.Records)
                if (r.Key.StartsWith(rootpath, Utility.Utility.ClientFilenameStringComparision))
                {
                    bool isFolder = (r.Value.FileAttributes & Win32USN.EFileAttributes.Directory) != 0;

                    if (excludedFolders != null && excludedFolders.Match(r.Key).Success)
                        continue;

                    if (isFolder)
                    {
                        if (!callback(rootpath, r.Key, (System.IO.FileAttributes)((int)r.Value.FileAttributes & 0xff)))
                        {
                            if (local_filter.Length != 0)
                                local_filter.Append("|");
                            local_filter.Append("(");
                            local_filter.Append(Utility.FilenameFilter.ConvertGlobbingToRegExp(r.Key + "*"));
                            local_filter.Append(")");

                            if (Utility.Utility.IsFSCaseSensitive)
                                excludedFolders = new System.Text.RegularExpressions.Regex(local_filter.ToString());
                            else
                                excludedFolders = new System.Text.RegularExpressions.Regex(local_filter.ToString(), System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                        }
                    }
                    else
                    {
                        if (local_filter.Length == 0 || !excludedFolders.IsMatch(r.Key))
                            callback(rootpath, r.Key, (System.IO.FileAttributes)((int)r.Value.FileAttributes & 0xff));
                    }
                }
        }
Beispiel #24
0
 private static void PrintBackend(XervBackup.Library.Interface.IBackend back, List<string> lines)
 {
     lines.Add(back.DisplayName + " (" + back.ProtocolKey + "):");
     lines.Add(" " + back.Description);
     if (back.SupportedCommands != null && back.SupportedCommands.Count > 0)
     {
         lines.Add(" " + Strings.Program.SupportedOptionsHeader);
         foreach (Library.Interface.ICommandLineArgument arg in back.SupportedCommands)
             Library.Interface.CommandLineArgument.PrintArgument(lines, arg, "  ");
     }
     lines.Add("");
 }
Beispiel #25
0
        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;
        }
Beispiel #26
0
 private static void PrintGenericModule(XervBackup.Library.Interface.IGenericModule mod, List<string> lines)
 {
     lines.Add(mod.DisplayName + " (" + mod.Key + "):");
     lines.Add(" " + mod.Description);
     lines.Add(" " + (mod.LoadAsDefault ? Strings.Program.ModuleIsLoadedAutomatically : Strings.Program.ModuleIsNotLoadedAutomatically));
     if (mod.SupportedCommands != null && mod.SupportedCommands.Count > 0)
     {
         lines.Add(" " + Strings.Program.SupportedOptionsHeader);
         foreach (Library.Interface.ICommandLineArgument arg in mod.SupportedCommands)
             Library.Interface.CommandLineArgument.PrintArgument(lines, arg, "  ");
     }
     lines.Add("");
 }
 /// <summary>
 /// Create new node with backup type and date
 /// </summary>
 private TreeNode NewNode(XervBackup.Library.Main.ManifestEntry aEntry)
 {
     TreeNode Result = new TreeNode((aEntry.IsFull ? "Full: " : "Inc: ") + aEntry.Time.ToString("ddd MM/dd/yyyy hh:mm tt"));
     Result.Tag = aEntry;
     return Result;
 }