private void SavePeriodicBackup(string databaseName, PeriodicBackupSettingsSectionModel periodicBackup) { if (periodicBackup.PeriodicBackupSetup == null) { return; } if (periodicBackup.IsS3Selected.Value) { periodicBackup.PeriodicBackupSetup.GlacierVaultName = string.Empty; } else { periodicBackup.PeriodicBackupSetup.S3BucketName = string.Empty; } settingsModel.DatabaseDocument.SecuredSettings["Raven/AWSSecretKey"] = periodicBackup.AwsSecretKey; settingsModel.DatabaseDocument.Settings["Raven/AWSAccessKey"] = periodicBackup.AwsAccessKey; DatabaseCommands.CreateDatabaseAsync(settingsModel.DatabaseDocument); var session = ApplicationModel.Current.Server.Value.DocumentStore.OpenAsyncSession(databaseName); session.Store(periodicBackup.PeriodicBackupSetup, PeriodicBackupSetup.RavenDocumentKey); session.SaveChangesAsync(); }
private async Task SavePeriodicBackup(PeriodicBackupSettingsSectionModel periodicBackup, IAsyncDocumentSession session) { if (periodicBackup.PeriodicBackupSetup == null) { return; } switch (periodicBackup.SelectedOption.Value) { case 0: periodicBackup.PeriodicBackupSetup.GlacierVaultName = null; periodicBackup.PeriodicBackupSetup.S3BucketName = null; periodicBackup.PeriodicBackupSetup.AzureStorageContainer = null; break; case 1: periodicBackup.PeriodicBackupSetup.LocalFolderName = null; periodicBackup.PeriodicBackupSetup.S3BucketName = null; periodicBackup.PeriodicBackupSetup.AzureStorageContainer = null; break; case 2: periodicBackup.PeriodicBackupSetup.GlacierVaultName = null; periodicBackup.PeriodicBackupSetup.LocalFolderName = null; periodicBackup.PeriodicBackupSetup.AzureStorageContainer = null; break; case 3: periodicBackup.PeriodicBackupSetup.GlacierVaultName = null; periodicBackup.PeriodicBackupSetup.S3BucketName = null; periodicBackup.PeriodicBackupSetup.LocalFolderName = null; break; } settingsModel.DatabaseDocument.SecuredSettings["Raven/AWSSecretKey"] = periodicBackup.PeriodicBackupSettings.AwsSecretKey; settingsModel.DatabaseDocument.Settings["Raven/AWSAccessKey"] = periodicBackup.PeriodicBackupSettings.AwsAccessKey; settingsModel.DatabaseDocument.SecuredSettings["Raven/AzureStorageKey"] = periodicBackup.PeriodicBackupSettings.AzureStorageKey; settingsModel.DatabaseDocument.Settings["Raven/AzureStorageAccount"] = periodicBackup.PeriodicBackupSettings.AzureStorageAccount; string activeBundles; settingsModel.DatabaseDocument.Settings.TryGetValue("Raven/ActiveBundles", out activeBundles); if (activeBundles == null || activeBundles.Contains("PeriodicBackup") == false) { activeBundles = "PeriodicBackup;" + activeBundles; } settingsModel.DatabaseDocument.Settings["Raven/ActiveBundles"] = activeBundles; await DatabaseCommands.GlobalAdmin.CreateDatabaseAsync(settingsModel.DatabaseDocument); await session.StoreAsync(periodicBackup.PeriodicBackupSetup, PeriodicBackupSetup.RavenDocumentKey); needToSaveChanges = true; }
private void SavePeriodicBackup(string databaseName, PeriodicBackupSettingsSectionModel periodicBackup) { if (periodicBackup.PeriodicBackupSetup == null) { return; } switch (periodicBackup.SelectedOption.Value) { case 0: periodicBackup.PeriodicBackupSetup.GlacierVaultName = null; periodicBackup.PeriodicBackupSetup.S3BucketName = null; break; case 1: periodicBackup.PeriodicBackupSetup.LocalFolderName = null; periodicBackup.PeriodicBackupSetup.S3BucketName = null; break; case 2: periodicBackup.PeriodicBackupSetup.GlacierVaultName = null; periodicBackup.PeriodicBackupSetup.LocalFolderName = null; break; } settingsModel.DatabaseDocument.SecuredSettings["Raven/AWSSecretKey"] = periodicBackup.AwsSecretKey; settingsModel.DatabaseDocument.Settings["Raven/AWSAccessKey"] = periodicBackup.AwsAccessKey; string activeBundles; settingsModel.DatabaseDocument.Settings.TryGetValue("Raven/ActiveBundles", out activeBundles); if (activeBundles == null || activeBundles.Contains("PeriodicBackup") == false) { activeBundles = "PeriodicBackup;" + activeBundles; } settingsModel.DatabaseDocument.Settings["Raven/ActiveBundles"] = activeBundles; DatabaseCommands.CreateDatabaseAsync(settingsModel.DatabaseDocument); var session = ApplicationModel.Current.Server.Value.DocumentStore.OpenAsyncSession(databaseName); session.Store(periodicBackup.PeriodicBackupSetup, PeriodicBackupSetup.RavenDocumentKey); session.SaveChangesAsync(); }
private async Task SavePeriodicBackup(PeriodicBackupSettingsSectionModel periodicBackup, IAsyncDocumentSession session) { if(periodicBackup.PeriodicBackupSetup == null) return; switch (periodicBackup.SelectedOption.Value) { case 0: periodicBackup.PeriodicBackupSetup.GlacierVaultName = null; periodicBackup.PeriodicBackupSetup.S3BucketName = null; periodicBackup.PeriodicBackupSetup.AzureStorageContainer = null; break; case 1: periodicBackup.PeriodicBackupSetup.LocalFolderName = null; periodicBackup.PeriodicBackupSetup.S3BucketName = null; periodicBackup.PeriodicBackupSetup.AzureStorageContainer = null; break; case 2: periodicBackup.PeriodicBackupSetup.GlacierVaultName = null; periodicBackup.PeriodicBackupSetup.LocalFolderName = null; periodicBackup.PeriodicBackupSetup.AzureStorageContainer = null; break; case 3: periodicBackup.PeriodicBackupSetup.GlacierVaultName = null; periodicBackup.PeriodicBackupSetup.S3BucketName = null; periodicBackup.PeriodicBackupSetup.LocalFolderName = null; break; } settingsModel.DatabaseDocument.SecuredSettings["Raven/AWSSecretKey"] = periodicBackup.AwsSecretKey; settingsModel.DatabaseDocument.Settings["Raven/AWSAccessKey"] = periodicBackup.AwsAccessKey; settingsModel.DatabaseDocument.SecuredSettings["Raven/AzureStorageKey"] = periodicBackup.AzureStorageKey; settingsModel.DatabaseDocument.Settings["Raven/AzureStorageAccount"] = periodicBackup.AzureStorageAccount; string activeBundles; settingsModel.DatabaseDocument.Settings.TryGetValue("Raven/ActiveBundles", out activeBundles); if (activeBundles == null || activeBundles.Contains("PeriodicBackup") == false) { activeBundles = "PeriodicBackup;" + activeBundles; } settingsModel.DatabaseDocument.Settings["Raven/ActiveBundles"] = activeBundles; await DatabaseCommands.CreateDatabaseAsync(settingsModel.DatabaseDocument); session.Store(periodicBackup.PeriodicBackupSetup, PeriodicBackupSetup.RavenDocumentKey); needToSaveChanges = true; }