private UploaderSettings GenerateUploaderSetting(Config.Categories.BackupConfiguration configuration) { var s3Settings = BackupTask.GetBackupConfigurationFromScript(Configuration.Connection.S3Settings, x => JsonDeserializationServer.S3Settings(x), Database, updateServerWideSettingsFunc: null, serverWide: false); var azureSettings = BackupTask.GetBackupConfigurationFromScript(Configuration.Connection.AzureSettings, x => JsonDeserializationServer.AzureSettings(x), Database, updateServerWideSettingsFunc: null, serverWide: false); var glacierSettings = BackupTask.GetBackupConfigurationFromScript(Configuration.Connection.GlacierSettings, x => JsonDeserializationServer.GlacierSettings(x), Database, updateServerWideSettingsFunc: null, serverWide: false); var googleCloudSettings = BackupTask.GetBackupConfigurationFromScript(Configuration.Connection.GoogleCloudSettings, x => JsonDeserializationServer.GoogleCloudSettings(x), Database, updateServerWideSettingsFunc: null, serverWide: false); var ftpSettings = BackupTask.GetBackupConfigurationFromScript(Configuration.Connection.FtpSettings, x => JsonDeserializationServer.FtpSettings(x), Database, updateServerWideSettingsFunc: null, serverWide: false); return(new UploaderSettings(configuration) { S3Settings = s3Settings, AzureSettings = azureSettings, GlacierSettings = glacierSettings, GoogleCloudSettings = googleCloudSettings, FtpSettings = ftpSettings, DatabaseName = Database.Name, TaskName = Name }); }
public RavenAwsGlacierClient(GlacierSettings glacierSettings, Config.Categories.BackupConfiguration configuration, Progress progress = null, CancellationToken cancellationToken = default) { if (glacierSettings == null) { throw new ArgumentNullException(nameof(glacierSettings)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (string.IsNullOrWhiteSpace(glacierSettings.AwsAccessKey)) { throw new ArgumentException("AWS Access Key cannot be null or empty"); } if (string.IsNullOrWhiteSpace(glacierSettings.AwsSecretKey)) { throw new ArgumentException("AWS Secret Key cannot be null or empty"); } if (string.IsNullOrWhiteSpace(glacierSettings.VaultName)) { throw new ArgumentException("AWS Vault Name cannot be null or empty"); } if (string.IsNullOrWhiteSpace(glacierSettings.AwsRegionName)) { throw new ArgumentException("AWS Region Name cannot be null or empty"); } var region = RegionEndpoint.GetBySystemName(glacierSettings.AwsRegionName); AWSCredentials credentials; if (string.IsNullOrWhiteSpace(glacierSettings.AwsSessionToken)) { credentials = new BasicAWSCredentials(glacierSettings.AwsAccessKey, glacierSettings.AwsSecretKey); } else { credentials = new SessionAWSCredentials(glacierSettings.AwsAccessKey, glacierSettings.AwsSecretKey, glacierSettings.AwsSessionToken); } _client = new AmazonGlacierClient(credentials, new AmazonGlacierConfig { RegionEndpoint = region, Timeout = configuration.CloudStorageOperationTimeout.AsTimeSpan }); _region = glacierSettings.AwsRegionName; _vaultName = glacierSettings.VaultName; _progress = progress; _cancellationToken = cancellationToken; }
public RavenGoogleCloudClient(GoogleCloudSettings settings, Config.Categories.BackupConfiguration configuration, Progress progress = null, CancellationToken?cancellationToken = null) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (string.IsNullOrWhiteSpace(settings.BucketName)) { throw new ArgumentException("Google Cloud Bucket name cannot be null or empty"); } if (string.IsNullOrWhiteSpace(settings.GoogleCredentialsJson)) { throw new ArgumentException("Google Credentials JSON cannot be null or empty"); } try { _client = StorageClient.Create(GoogleCredential.FromJson(settings.GoogleCredentialsJson)); _client.Service.HttpClient.Timeout = configuration.CloudStorageOperationTimeout.AsTimeSpan; } catch (Exception e) { throw new ArgumentException("Wrong format for Google Credentials.", e); } var credentialJsonType = JObject.Parse(settings.GoogleCredentialsJson); if (credentialJsonType.TryGetValue(ProjectIdPropertyName, StringComparison.OrdinalIgnoreCase, out var value)) { _projectId = value.Value <string>(); } _bucketName = settings.BucketName; CancellationToken = cancellationToken ?? CancellationToken.None; _progress = progress; }
public RavenAwsS3Client(S3Settings s3Settings, Config.Categories.BackupConfiguration configuration, Progress progress = null, CancellationToken cancellationToken = default) { if (s3Settings == null) { throw new ArgumentNullException(nameof(s3Settings)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (string.IsNullOrWhiteSpace(s3Settings.AwsAccessKey)) { throw new ArgumentException("AWS Access Key cannot be null or empty"); } if (string.IsNullOrWhiteSpace(s3Settings.AwsSecretKey)) { throw new ArgumentException("AWS Secret Key cannot be null or empty"); } if (string.IsNullOrWhiteSpace(s3Settings.BucketName)) { throw new ArgumentException("AWS Bucket Name cannot be null or empty"); } var config = new AmazonS3Config { Timeout = configuration.CloudStorageOperationTimeout.AsTimeSpan }; if (string.IsNullOrWhiteSpace(s3Settings.CustomServerUrl)) { if (string.IsNullOrWhiteSpace(s3Settings.AwsRegionName)) { throw new ArgumentException("AWS Region Name cannot be null or empty"); } config.RegionEndpoint = RegionEndpoint.GetBySystemName(s3Settings.AwsRegionName); } else { config.UseHttp = true; config.ForcePathStyle = s3Settings.ForcePathStyle; config.ServiceURL = s3Settings.CustomServerUrl; } AWSCredentials credentials; if (string.IsNullOrWhiteSpace(s3Settings.AwsSessionToken)) { credentials = new BasicAWSCredentials(s3Settings.AwsAccessKey, s3Settings.AwsSecretKey); } else { credentials = new SessionAWSCredentials(s3Settings.AwsAccessKey, s3Settings.AwsSecretKey, s3Settings.AwsSessionToken); } _client = new AmazonS3Client(credentials, config); _bucketName = s3Settings.BucketName; RemoteFolderName = s3Settings.RemoteFolderName; Region = s3Settings.AwsRegionName == null ? string.Empty : s3Settings.AwsRegionName.ToLower(); _progress = progress; _cancellationToken = cancellationToken; }
public GoogleCloudRestorePoints(Config.Categories.BackupConfiguration configuration, SortedList <DateTime, RestorePoint> sortedList, TransactionOperationContext context, GoogleCloudSettings client) : base(sortedList, context) { _configuration = configuration; _client = new RavenGoogleCloudClient(client, configuration); }
public AzureRestorePoints(Config.Categories.BackupConfiguration configuration, SortedList <DateTime, RestorePoint> sortedList, TransactionOperationContext context, AzureSettings azureSettings) : base(sortedList, context) { _configuration = configuration; _client = RavenAzureClient.Create(azureSettings, configuration); }
public S3RestorePoints(Config.Categories.BackupConfiguration configuration, SortedList <DateTime, RestorePoint> sortedList, TransactionOperationContext context, S3Settings s3Settings) : base(sortedList, context) { _configuration = configuration; _client = new RavenAwsS3Client(s3Settings, configuration); }
public BackupUploaderSettings(Config.Categories.BackupConfiguration configuration) { Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); }