private AzureSqlDatabaseLongTermRetentionBackupModel GetBackupModel(Management.Sql.Models.LongTermRetentionBackup backup, string locationName) { return(new AzureSqlDatabaseLongTermRetentionBackupModel() { BackupExpirationTime = backup.BackupExpirationTime, BackupName = backup.Name, BackupTime = backup.BackupTime, DatabaseDeletionTime = backup.DatabaseDeletionTime, DatabaseName = backup.DatabaseName, Location = locationName, ResourceId = backup.Id, ServerCreateTime = backup.ServerCreateTime, ServerName = backup.ServerName }); }
/// <summary> /// Update a Long Term Retention backup. /// </summary> /// <param name="locationName">The location name.</param> /// <param name="serverName">The server name.</param> /// <param name="databaseName">The database name.</param> /// <param name="backupName">The backup name.</param> /// <param name="resourceGroupName">The resource group name</param> /// <param name="onlyLatestPerDatabase">Whether or not to only get the latest backup per database.</param> /// <param name="databaseState">The state of databases to get backups for: All, Live, Deleted.</param> internal AzureSqlDatabaseLongTermRetentionBackupCopyModel CopyDatabaseLongTermRetentionBackup( AzureSqlDatabaseLongTermRetentionBackupCopyModel model) { Management.Sql.Models.LongTermRetentionBackupOperationResult response = Communicator.CopyDatabaseLongTermRetentionBackup( model.SourceLocation, model.SourceServerName, model.SourceDatabaseName, model.SourceBackupName, model.SourceResourceGroupName, new Management.Sql.Models.CopyLongTermRetentionBackupParameters() { TargetServerFullyQualifiedDomainName = model.TargetServerFullyQualifiedDomainName, TargetDatabaseName = model.TargetDatabaseName, TargetServerResourceId = model.TargetServerResourceId, TargetSubscriptionId = model.TargetSubscriptionId, TargetResourceGroup = model.TargetResourceGroupName }); Management.Sql.Models.LongTermRetentionBackup sourceBackup = Communicator.GetDatabaseLongTermRetentionBackup( model.SourceLocation, model.SourceServerName, model.SourceDatabaseName, model.SourceBackupName, model.SourceResourceGroupName); Dictionary <string, string> targetBackupResourceIdSegments = ParseLongTermRentionBackupResourceId(response.ToBackupResourceId); string targetLocationName = targetBackupResourceIdSegments["locations"]; string targetServerName = targetBackupResourceIdSegments["longTermRetentionServers"]; string targetBackupName = targetBackupResourceIdSegments["longTermRetentionBackups"]; model.SourceBackupResourceId = response.FromBackupResourceId; model.SourceBackupStorageRedundancy = sourceBackup.BackupStorageRedundancy; model.TargetLocation = targetLocationName; model.TargetServerName = targetServerName; model.TargetBackupName = targetBackupName; model.TargetBackupResourceId = response.ToBackupResourceId; return(model); }
/// <summary> /// Update a Long Term Retention backup. /// </summary> /// <param name="locationName">The location name.</param> /// <param name="serverName">The server name.</param> /// <param name="databaseName">The database name.</param> /// <param name="backupName">The backup name.</param> /// <param name="resourceGroupName">The resource group name</param> /// <param name="onlyLatestPerDatabase">Whether or not to only get the latest backup per database.</param> /// <param name="databaseState">The state of databases to get backups for: All, Live, De /// leted.</param> internal AzureSqlDatabaseLongTermRetentionBackupModel UpdateDatabaseLongTermRetentionBackup( AzureSqlDatabaseLongTermRetentionBackupModel model, Management.Sql.Models.UpdateLongTermRetentionBackupParameters updateParameters) { Management.Sql.Models.LongTermRetentionBackupOperationResult response = Communicator.UpdateDatabaseLongTermRetentionBackup( model.Location, model.ServerName, model.DatabaseName, model.BackupName, model.ResourceGroupName, updateParameters); Management.Sql.Models.LongTermRetentionBackup backup = Communicator.GetDatabaseLongTermRetentionBackup( model.Location, model.ServerName, model.DatabaseName, model.BackupName, model.ResourceGroupName); AzureSqlDatabaseLongTermRetentionBackupModel backupModel = GetBackupModel(backup, model.Location); return(backupModel); }