Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RecoveryServices.Backup] Enabled Softdelete feature for SQL Backup items #13680

Merged
merged 1 commit into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ public AzureWorkloadSQLDatabaseProtectedItem(ProtectedItemResource protectedItem
ProtectionState =
EnumUtils.GetEnum<ItemProtectionState>(protectedItem.ProtectionState.ToString());
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);
DateOfPurge = null;
DeleteState = EnumUtils.GetEnum<ItemDeleteState>("NotDeleted");
if (protectedItem.IsScheduledForDeferredDelete.HasValue)
{
DateOfPurge = protectedItem.DeferredDeleteTimeInUTC.Value.AddDays(14);
DeleteState = EnumUtils.GetEnum<ItemDeleteState>("ToBeDeleted");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,32 @@ public RestAzureNS.AzureOperationResponse DisableProtectionWithDeleteData()

public RestAzureNS.AzureOperationResponse<ProtectedItemResource> UndeleteProtection()
{
throw new Exception(Resources.SoftdeleteNotImplementedException);
string vaultName = (string)ProviderData[VaultParams.VaultName];
string resourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName];
AzureWorkloadSQLDatabaseProtectedItem item = (AzureWorkloadSQLDatabaseProtectedItem)ProviderData[ItemParams.Item];

Dictionary<UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.Id);
string containerUri = HelperUtils.GetContainerUri(keyValueDict, item.Id);
string protectedItemUri = HelperUtils.GetProtectedItemUri(keyValueDict, item.Id);

AzureVmWorkloadSQLDatabaseProtectedItem properties = new AzureVmWorkloadSQLDatabaseProtectedItem();

properties.PolicyId = null;
properties.ProtectionState = ProtectionState.ProtectionStopped;
properties.SourceResourceId = item.SourceResourceId;
properties.IsRehydrate = true;

ProtectedItemResource serviceClientRequest = new ProtectedItemResource()
{
Properties = properties,
};

return ServiceClientAdapter.CreateOrUpdateProtectedItem(
containerUri,
protectedItemUri,
serviceClientRequest,
vaultName: vaultName,
resourceGroupName: resourceGroupName);
}

public RestAzureNS.AzureOperationResponse<ProtectedItemResource> EnableProtection()
Expand Down
1 change: 1 addition & 0 deletions src/RecoveryServices/RecoveryServices/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Enabled softdelete feature for SQL.

## Version 3.1.0
* Made help text and parameter set name changes to `Restore-AzRecoveryServicesBackupItem` cmdlet.
Expand Down