public BackupProject Clone() { BackupProject cp = new BackupProject(); cp.Name = Name; cp.BackupFolder = BackupFolder; cp.SourceFolder = SourceFolder; cp.Password = Password; cp.SafePassword = SafePassword.Clone(); cp.ExcludeExtensions = new List <string>(); foreach (string ss in ExcludeExtensions) { cp.ExcludeExtensions.Add(ss); } cp.ExcludeFiles = new List <string>(); foreach (string ss in ExcludeFiles) { cp.ExcludeFiles.Add(ss); } cp.SourceCredentials = SourceCredentials.Clone(); cp.BackupCredentials = BackupCredentials.Clone(); cp.UseVolumeShadowService = UseVolumeShadowService; cp.DoNotRemind = DoNotRemind; cp.AlternativePassword = AlternativePassword; lock (ArchiveFileList) cp.ArchiveFileList = ArchiveFileList.Clone(); cp.MostRecentBackup = MostRecentBackup; // The Manifest Cache is not cloned. return(cp); }
/// <summary> /// OnNewBackup is similar to Refresh(), but is called whenever a backup run has completed /// that generated a new backup archive (i.e. files had changed). It is called immediately /// after the backup run is completed. /// </summary> public void OnNewBackup() { lock (ArchiveFileList) using (NetworkConnection newself = new NetworkConnection(CompleteBackupFolder, BackupCredentials)) ArchiveFileList.LoadAll(this); }
public void Refresh(bool PromptForPassword) { try { LastRefresh = DateTime.Now; ArchiveFilename MostRecent; lock (ArchiveFileList) { using (NetworkConnection newself = new NetworkConnection(CompleteBackupFolder, BackupCredentials)) ArchiveFileList.LoadAll(this); // Locate most recent backup... MostRecent = ArchiveFileList.FindMostRecent(); } if (MostRecent == ArchiveFilename.MaxValue) { MostRecentBackup = DateTime.MinValue; } else { try { Manifest Manifest; using (NetworkConnection newself = new NetworkConnection(CompleteBackupFolder, BackupCredentials)) Manifest = MostRecent.LoadArchiveManifest(this, PromptForPassword); MostRecentBackup = Manifest.BackupStartTime; } catch (Ionic.Zip.BadPasswordException bpe) { if (PromptForPassword) { throw bpe; } else { MostRecentBackup = MostRecent.BackupDate; } } } // Also check for an Backup_Status.xml file... // This file is created with each backup, and is particularly helpful when we have an 'empty backup' // where no archive need be created (because nothing has changed). We need to display to the user that // the project was backed up recently, but we needn't create an archive. The Backup_Status.xml file // accomplishes this. FileInfo[] FileList = new DirectoryInfo(CompleteBackupFolder).GetFiles("Backup_Status.xml"); if (FileList.Length > 0) { BackupStatus Status = null; try { Status = BackupStatus.Load(FileList[0].FullName); } catch (Exception exc) { MessageBox.Show("Unable to load backup status file (see error details below). This file helps ZippyBackup keep track of some things, but we can also figure it out from scratch and make a new backup status file when you perform your next backup. Click OK and ZippyBackup will proceed without it. Your next backup may take longer than usual.\n\nDetailed error information: " + exc.Message); } if (Status != null) { if (MostRecent != ArchiveFilename.MaxValue && Status.LastArchive == MostRecent.ToString() && Status.LastBackup.ToUniversalTime() > MostRecentBackup.ToUniversalTime()) { MostRecentBackup = Status.LastBackup; } MostRecentCompleteBackup = Status.LastCompletedBackup; LastScanRelativePath = Status.LastScanRelativePath; LastVerifyRelativePath = Status.LastVerifyRelativePath; MostRecentVerify = Status.LastVerify; MostRecentCompleteVerify = Status.LastCompletedVerify; } } // Clear out the manifest cache... lock (ManifestCache) ManifestCache.Clear(); LoadIssue = false; } catch (System.Security.Authentication.InvalidCredentialException) { LoadIssue = true; } catch (IOException) { LoadIssue = true; } }