Exemple #1
0
        private async Task <List <string> > GetBackupLocationsInBackupChainInternalAsync(string backupLocation, CancellationToken cancellationToken)
        {
            var backupLocationList = new List <string>();
            var fullBackupLocation = backupLocation;

            // Check if backup exists
            if (!CheckIfBackupExists(fullBackupLocation))
            {
                throw new FabricElementNotFoundException(String.Format("Missing backup!! Couldn't find backup folder {0} which is there in backup chain", fullBackupLocation));
            }

            var recoveryPointMetadataFileName = GetRecoveryPointMetadataFileNameFromBackupLocation(fullBackupLocation);
            RecoveryPointMetadataFile recoveryPointMetadataFile = null;

            using (MemoryStream ms = new MemoryStream())
            {
                CloudBlockBlob blockBlob = AzureBlobStoreHelper.GetCloudBlockBlobRef(this.container, recoveryPointMetadataFileName);
                await AzureBlobStoreHelper.DownloadToStreamAsync(blockBlob, ms, cancellationToken);

                recoveryPointMetadataFile = await RecoveryPointMetadataFile.OpenAsync(ms, recoveryPointMetadataFileName, cancellationToken);
            }

            backupLocationList.Add(recoveryPointMetadataFile.BackupLocation);

            while (recoveryPointMetadataFile.ParentBackupId != Guid.Empty)
            {
                fullBackupLocation = recoveryPointMetadataFile.ParentBackupLocation;

                // Check if backup folder exists
                if (!CheckIfBackupExists(fullBackupLocation))
                {
                    throw new FabricElementNotFoundException(String.Format("Missing backup!! Couldn't find backup folder {0} which is there in backup chain", fullBackupLocation));
                }

                recoveryPointMetadataFileName = GetRecoveryPointMetadataFileNameFromBackupLocation(fullBackupLocation);
                using (MemoryStream ms = new MemoryStream())
                {
                    CloudBlockBlob blockBlob = AzureBlobStoreHelper.GetCloudBlockBlobRef(this.container, recoveryPointMetadataFileName);
                    await AzureBlobStoreHelper.DownloadToStreamAsync(blockBlob, ms, cancellationToken);

                    recoveryPointMetadataFile = await RecoveryPointMetadataFile.OpenAsync(ms, recoveryPointMetadataFileName, cancellationToken);

                    backupLocationList.Add(recoveryPointMetadataFile.BackupLocation);
                }
            }

            Debug.Assert(recoveryPointMetadataFile.BackupId == recoveryPointMetadataFile.BackupChainId, "Backup ID for root doesn't match with backup chain ID");
            return(backupLocationList);
        }
Exemple #2
0
        private async Task <List <RestorePoint> > GetRecoveryPointDetailsInternalAsync(IEnumerable <string> metadataFiles, CancellationToken cancellationToken)
        {
            var backupList = new List <RestorePoint>();

            foreach (var metadataFile in metadataFiles)
            {
                cancellationToken.ThrowIfCancellationRequested();

                using (MemoryStream ms = new MemoryStream())
                {
                    CloudBlockBlob blockBlob = AzureBlobStoreHelper.GetCloudBlockBlobRef(this.container, metadataFile);
                    await AzureBlobStoreHelper.DownloadToStreamAsync(blockBlob, ms, cancellationToken);

                    var recoveryPointMetadataFile =
                        await RecoveryPointMetadataFile.OpenAsync(ms, metadataFile, cancellationToken);

                    var recoveryPoint = new RestorePoint()
                    {
                        BackupChainId        = recoveryPointMetadataFile.BackupChainId,
                        BackupId             = recoveryPointMetadataFile.BackupId,
                        ParentRestorePointId = recoveryPointMetadataFile.ParentBackupId,
                        BackupLocation       = recoveryPointMetadataFile.BackupLocation,
                        CreationTimeUtc      = recoveryPointMetadataFile.BackupTime,
                        BackupType           =
                            recoveryPointMetadataFile.ParentBackupId == Guid.Empty ? BackupOptionType.Full : BackupOptionType.Incremental,
                        EpochOfLastBackupRecord = new BackupEpoch
                        {
                            ConfigurationNumber = recoveryPointMetadataFile.EpochOfLastBackupRecord.ConfigurationNumber,
                            DataLossNumber      = recoveryPointMetadataFile.EpochOfLastBackupRecord.DataLossNumber
                        },
                        LsnOfLastBackupRecord  = recoveryPointMetadataFile.LsnOfLastBackupRecord,
                        PartitionInformation   = this.GetBackupServicePartitionInformationFromServicePartitionInformation(recoveryPointMetadataFile.PartitionInformation),
                        ServiceManifestVersion = recoveryPointMetadataFile.ServiceManifestVersion,
                    };

                    PopulateApplicationServiceAndPartitionInfo(recoveryPoint, metadataFile);

                    backupList.Add(recoveryPoint);
                }
            }

            return(backupList);
        }
Exemple #3
0
        private async Task <List <string> > GetBackupLocationsInBackupChainInternalAsync(string backupLocation, CancellationToken cancellationToken)
        {
            var backupLocationList = new List <string>();

            var fullBackupLocation = Path.Combine(this.storeInformation.Path, backupLocation);

            // Check if backup exists
            if (!CheckIfBackupExists(fullBackupLocation))
            {
                throw new FabricElementNotFoundException(String.Format("Missing backup!! Couldnt find backup folder {0} which is there in backup chain", fullBackupLocation));
            }

            var recoveryPointMetadataFileName = GetRecoveryPointMetadataFileNameFromBackupLocation(fullBackupLocation);
            var recoveryPointMetadataFile     = await RecoveryPointMetadataFile.OpenAsync(recoveryPointMetadataFileName, cancellationToken);

            backupLocationList.Add(recoveryPointMetadataFile.BackupLocation);

            while (recoveryPointMetadataFile.ParentBackupId != Guid.Empty)
            {
                fullBackupLocation = Path.Combine(this.storeInformation.Path,
                                                  recoveryPointMetadataFile.ParentBackupLocation);

                // Check if backup folder exists
                if (!CheckIfBackupExists(fullBackupLocation))
                {
                    throw new FabricElementNotFoundException(String.Format("Missing backup!! Couldnt find backup folder {0} which is there in backup chain", fullBackupLocation));
                }

                recoveryPointMetadataFileName = GetRecoveryPointMetadataFileNameFromBackupLocation(fullBackupLocation);
                recoveryPointMetadataFile     = await RecoveryPointMetadataFile.OpenAsync(recoveryPointMetadataFileName, cancellationToken);

                backupLocationList.Add(recoveryPointMetadataFile.BackupLocation);
            }

            Debug.Assert(recoveryPointMetadataFile.BackupId == recoveryPointMetadataFile.BackupChainId, "Backup ID for root doesnt match with backup chain ID");
            return(backupLocationList);
        }
Exemple #4
0
        private async Task <List <RestorePoint> > GetRecoveryPointDetailsInternalAsync(IEnumerable <string> metadataFiles, CancellationToken cancellationToken)
        {
            var backupList = new List <RestorePoint>();

            foreach (var metadataFile in metadataFiles)
            {
                cancellationToken.ThrowIfCancellationRequested();

                var recoveryPointMetadataFile =
                    await RecoveryPointMetadataFile.OpenAsync(Path.Combine(this.storeInformation.Path, metadataFile), cancellationToken);

                var recoveryPoint = new RestorePoint()
                {
                    BackupChainId        = recoveryPointMetadataFile.BackupChainId,
                    BackupId             = recoveryPointMetadataFile.BackupId,
                    ParentRestorePointId = recoveryPointMetadataFile.ParentBackupId,
                    BackupLocation       = recoveryPointMetadataFile.BackupLocation,
                    CreationTimeUtc      = recoveryPointMetadataFile.BackupTime,
                    BackupType           =
                        recoveryPointMetadataFile.ParentBackupId == Guid.Empty? BackupOptionType.Full : BackupOptionType.Incremental,
                    EpochOfLastBackupRecord = new BackupEpoch
                    {
                        ConfigurationNumber = recoveryPointMetadataFile.EpochOfLastBackupRecord.ConfigurationNumber,
                        DataLossNumber      = recoveryPointMetadataFile.EpochOfLastBackupRecord.DataLossNumber
                    },
                    LsnOfLastBackupRecord  = recoveryPointMetadataFile.LsnOfLastBackupRecord,
                    PartitionInformation   = this.GetBackupServicePartitionInformationFromServicePartitionInformation(recoveryPointMetadataFile.PartitionInformation),
                    ServiceManifestVersion = recoveryPointMetadataFile.ServiceManifestVersion,
                };

                PopulateApplicationServiceAndPartitionInfo(recoveryPoint, metadataFile);

                backupList.Add(recoveryPoint);
            }

            return(backupList);
        }