private async Task <bool> StoreBackupSets(IStorageLocation location, IBackupIndex filesToStore) { var results = true; foreach (var backupSet in filesToStore.BackupSets) { var basePath = backupSet.BasePath; var success = await StoreBranch(location, basePath, backupSet.Root); if (!success) { results = false; } } return(results); }
private IBackupIndex GetUnstoredFiles(IBackupIndex existingIndex, IBackupIndex previousIndex) { if (previousIndex == null) { return(existingIndex); } var diffIndex = new BackupIndex(); var allPreviousFileHashes = previousIndex.GetAllNodeHashes(); foreach (var existingBackupSet in existingIndex.BackupSets) { var diffBackupSet = diffIndex.AddBackupSet(existingBackupSet.BasePath, existingBackupSet.Root.Name); DiffBackupSets(existingBackupSet.Root, diffBackupSet.Root, allPreviousFileHashes); } return(diffIndex); }
/// <summary> /// Opens an existing backup archive /// </summary> public void Open() { try { // copy the backup index to a temporary location and open it this.tempIndex = IO.FileSystem.Temp(); IO.FileSystem.Copy(this.IndexPath, this.tempIndex.Path); this.backupIndex = Sqlite.BackupIndex.Open(this.tempIndex.Path); } catch { Dispose(); throw; } }
/// <summary> /// Releases the resources associated with the archive /// </summary> public void Dispose() { if (this.backupIndex != null) this.backupIndex.Dispose(); if (this.restoreIndex != null) this.restoreIndex.Dispose(); if (this.tempIndex != null) this.tempIndex.Dispose(); this.backupIndex = null; this.restoreIndex = null; this.tempIndex = null; }
/// <summary> /// Creates a new backup archive /// </summary> /// <param name="header"> /// The backup index header to insert /// </param> public void Create(Backup.Header header) { try { // create the archive directory IO.FileSystem.CreateDirectory(this.Path); // create the backup index within the temp path this.tempIndex = IO.FileSystem.Temp(); this.backupIndex = Sqlite.BackupIndex.Create(this.tempIndex.Path, header); this.backupIndex.InsertBlob( new Backup.Blob() { Name = this.BlobPath.FileName } ); // copy the initial version of the index to the archive path Save(); } catch { Dispose(); try { IO.FileSystem.Delete(this.Path); } catch { } throw; } }
/// <summary> /// Opens an existing archive /// </summary> public void Open() { // download the existing backup index this.backupIndexFile = IO.FileSystem.Temp(); using (var s3response = this.s3.GetObject( new Amazon.S3.Model.GetObjectRequest() { BucketName = this.bucket, Key = this.IndexS3Key } ) ) using (var s3Stream = s3response.ResponseStream) using (var gzip = new GZipStream(s3Stream, CompressionMode.Decompress)) this.copier.CopyAndFlush(gzip, this.backupIndexFile); // open the index this.backupIndex = Sqlite.BackupIndex.Open(this.backupIndexFile.Path); }
/// <summary> /// Creates a new archive /// </summary> /// <param name="header"> /// The backup index header to insert /// </param> public void Create(Backup.Header header) { // create the Glacier vault, fail if it exists this.glacier.CreateVault( new Amazon.Glacier.Model.CreateVaultRequest() { VaultName = this.vault } ); // create the local backup index file this.backupIndexFile = IO.FileSystem.Temp(); this.backupIndex = Sqlite.BackupIndex.Create( this.backupIndexFile.Path, header ); // sync the initialized archive to the S3 bucket Save(); }
public void AddBackup(IBackupIndex backup) { BackupIndexes.Add(backup); }