public BackupProgress StartBackup(BackupStorageType storageType, StorageParams storageParams, bool backupMail) { DemandPermissions(); var backupRequest = new StartBackupRequest { TenantId = GetCurrentTenantId(), UserId = SecurityContext.CurrentAccount.ID, BackupMail = backupMail, StorageType = storageType }; switch (storageType) { case BackupStorageType.ThridpartyDocuments: case BackupStorageType.Documents: backupRequest.StorageBasePath = storageParams.FolderId; break; case 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 }); break; } using (var service = new BackupServiceClient()) { return service.StartBackup(backupRequest); } }
public BackupProgress StartBackup(BackupStorageType storageType, StorageParams storageParams, bool backupMail) { DemandPermissionsBackup(); DemandSize(); var backupRequest = new StartBackupRequest { TenantId = GetCurrentTenantId(), UserId = SecurityContext.CurrentAccount.ID, BackupMail = backupMail, StorageType = storageType }; switch (storageType) { case BackupStorageType.ThridpartyDocuments: case BackupStorageType.Documents: backupRequest.StorageBasePath = storageParams.FolderId; break; case BackupStorageType.CustomCloud: backupRequest.StorageBasePath = storageParams.FilePath; 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 }); break; } MessageService.Send(HttpContext.Current.Request, MessageAction.StartBackupSetting); using (var service = new BackupServiceClient()) { return(service.StartBackup(backupRequest)); } }
public override string Check(int tenantId) { try { log.Debug("CheckBackupState"); using (var backupServiceClient = new BackupServiceClient()) { var status = backupServiceClient.StartBackup(new StartBackupRequest { TenantId = tenantId, StorageType = BackupStorageType.DataStore }); try { while (!status.IsCompleted) { Thread.Sleep(1000); status = backupServiceClient.GetBackupProgress(tenantId); } } catch (Exception ex) { log.ErrorFormat("Backup is failed! {0} {1} {2}", status.Error, ex.Message, ex.StackTrace); return(HealthCheckResource.BackupServiceWorksIncorrectMsg); } log.Debug("Backup is OK!"); return(string.Empty); } } catch (Exception ex) { log.ErrorFormat("Backup is failed! {0} {1} {2}", ex.Message, ex.StackTrace, ex.InnerException != null ? ex.InnerException.Message : string.Empty); return(HealthCheckResource.BackupServiceWorksIncorrectMsg); } }
public BackupProgress StartBackup(BackupStorageType storageType, Dictionary <string, string> storageParams, bool backupMail) { DemandPermissionsBackup(); DemandSize(); var backupRequest = new StartBackupRequest { TenantId = GetCurrentTenantId(), UserId = SecurityContext.CurrentAccount.ID, BackupMail = backupMail, StorageType = storageType, StorageParams = storageParams }; switch (storageType) { case BackupStorageType.ThridpartyDocuments: case BackupStorageType.Documents: backupRequest.StorageBasePath = storageParams["folderId"]; break; case BackupStorageType.Local: if (!CoreContext.Configuration.Standalone) { throw new Exception("Access denied"); } backupRequest.StorageBasePath = storageParams["filePath"]; break; } MessageService.Send(HttpContext.Current.Request, MessageAction.StartBackupSetting); using (var service = new BackupServiceClient()) { return(service.StartBackup(backupRequest)); } }