public BackupProgress StartRestore(StartRestoreRequest request)
 {
     return(Channel.StartRestore(request));
 }
Ejemplo n.º 2
0
        public BackupProgress StartRestore(string backupId, BackupStorageType storageType, StorageParams storageParams, bool notify)
        {
            DemandPermissions();

            var restoreRequest = new StartRestoreRequest
                {
                    TenantId = GetCurrentTenantId(),
                    NotifyAfterCompletion = notify
                };

            Guid guidBackupId;
            if (Guid.TryParse(backupId, out guidBackupId))
            {
                restoreRequest.BackupId = guidBackupId;
            }
            else
            {
                restoreRequest.StorageType = storageType;
                restoreRequest.FilePathOrId = storageParams.FilePath;
                if (storageType == BackupStorageType.CustomCloud)
                {
                    ValidateS3Settings(storageParams.AccessKeyId, storageParams.SecretAccessKey, storageParams.Bucket, storageParams.Region);
                    CoreContext.Configuration.SaveSection(new AmazonS3Settings
                        {
                            AccessKeyId = storageParams.AccessKeyId,
                            SecretAccessKey = storageParams.SecretAccessKey,
                            Bucket = storageParams.Bucket,
                            Region = storageParams.Region
                        });
                }
            }

            using (var service = new BackupServiceClient())
            {
                return service.StartRestore(restoreRequest);
            }
        }