ACS-HBR-SAPHanaRestorationAutomationByExistingECS: Validates an SAP HANA backup by restoring it to an existing instance.
Template description
Uses the Hybrid Backup Recovery (HBR) service to restore backup data from a source SAP HANA instance to an existing destination SAP HANA instance. After data restoration, this template checks the status of the destination instance. Execute now
Template type
Automation
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Constraints |
vaultId | The ID of the Hybrid Backup Recovery (HBR) backup vault. | String | Yes | ||
sourceClusterId | The ID of the source HBR instance. | String | Yes | ||
destinationClusterId | The ID of the destination HBR instance. | String | Yes | ||
HANASID | The system ID (SID) of the destination SAP HANA instance. | String | Yes | Regular expression: ^[A-Z][A-Z0-9][A-Z0-9]$ | |
ECSHostname | The hostname of the destination instance. | String | Yes | Regular expression: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-])*([a-zA-Z0-9])$ | |
HANAInstanceNumber | The instance number of the destination SAP HANA instance. | String | Yes | Regular expression: ^([0-8][0-9]|9[0-6])$ | |
dingTalkWebhook | The webhook URL of the DingTalk chatbot. | String | Yes | ||
databaseName | The list of database instances. | List | No | ['SYSTEMDB@<SID>:SYSTEMDB'] |
Output parameters
None
Required access policy
{
"Version": "1",
"Statement": [
{
"Action": [
"hbr:CreateHanaRestore",
"hbr:DescribeClients",
"hbr:DescribeHanaBackupSetting",
"hbr:DescribeHanaBackupsAsync",
"hbr:DescribeHanaRestores",
"hbr:DescribeTask",
"hbr:UpdateHanaBackupSetting"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:ListExecutions"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
For more information, see ACS-HBR-SAPHanaRestorationAutomationByExistingECS.yml on GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS-HBR-SAPHanaRestorationAutomationByExistingECS
en: This template uses existing SAP HANA instances (a source instance and a destination instance) to restore backup data from the source instance to the destination instance using the Hybrid Backup Recovery (HBR) service. It also checks the status of the destination instance after the restoration.
Parameters:
vaultId:
Label:
en: Backup Vault ID
Description:
en: The ID of the backup vault.
Type: String
sourceClusterId:
Label:
en: Source SAP HANA instance ID
Description:
en: 'The ID of the source SAP HANA instance. You can find this ID in the Hybrid Backup Recovery console. Go to ECS Application Backup and look in the Instance Name/ID column.'
Type: String
destinationClusterId:
Label:
en: Destination SAP HANA instance ID
Description:
en: 'The ID of the destination SAP HANA instance. You can find this ID in the Hybrid Backup Recovery console. Go to ECS Application Backup and look in the Instance Name/ID column.'
Type: String
databaseName:
Label:
en: SAP HANA Database List
Description:
en: 'A list of SAP HANA database instances to restore. Use the format: <Source_database_name>@<SID>:<Destination_database_name>. Separate multiple database instances with line breaks.'
Type: List
Default:
- 'SYSTEMDB@<SID>:SYSTEMDB'
HANASID:
Type: String
ConstraintDescription:
en: 'Must be 3 characters. It can contain uppercase letters and numbers, and must start with an uppercase letter.'
Label:
en: SAP HANA SID
Description:
en: The SID of the destination SAP HANA instance.
AllowedPattern: '^[A-Z][A-Z0-9][A-Z0-9]$'
ECSHostname:
Type: String
Label:
en: Hostname
Description:
en: The hostname of the SAP HANA ECS instance.
AllowedPattern: '^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-])*([a-zA-Z0-9])$'
ConstraintDescription:
en: 'The length must be 2 to 13 characters. It can contain letters, numbers, and hyphens (-), but cannot start or end with a hyphen.'
HANAInstanceNumber:
Type: String
Label:
en: SAP HANA Instance Number
Description:
en: The instance number of the SAP HANA instance.
ConstraintDescription:
en: 'A two-digit number from 00 to 97.'
AllowedPattern: '^([0-8][0-9]|9[0-6])$'
dingTalkWebhook:
Label:
en: DingTalk Robot Webhook
Description:
en: 'The webhook URL for a custom DingTalk chatbot. It is used to send test results and approval messages for deleting cloud resources. For more information, see <a href=''https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq'' target=''_blank''>Custom DingTalk Chatbots</a>.'
Type: String
Tasks:
- Name: checkHanaBackupSetting
Action: 'ACS::CheckFor'
Description:
en: Queries the database backup settings of the source SAP HANA instance.
Properties:
Service: HBR
API: DescribeHanaBackupSetting
Parameters:
VaultId: '{{ vaultId }}'
ClusterId: '{{ sourceClusterId }}'
DatabaseName:
'Fn::Select':
- 0
- 'Fn::Split':
- '@'
- '{{ ACS::TaskLoopItem }}'
PropertySelector: HanaBackupSetting.CatalogBackupUsingBackint
DesiredValues:
- true
Retries: 2
Loop:
Items: '{{ databaseName }}'
RateControl:
MaxErrors: 0
Mode: Concurrency
Concurrency: 1
- Name: checkForActivateClient
Action: 'ACS::CheckFor'
OnError: getExecutionFaildMessage
Description:
en: Checks whether the client is activated.
Properties:
Service: HBR
API: DescribeClients
Parameters:
ClusterId: '{{ destinationClusterId }}'
VaultId: '{{ vaultId }}'
SourceType: HANA
ClientType: ECS_AGENT
PropertySelector: 'Clients.Client[].Status'
DesiredValues:
- ACTIVATED
Retries: 2
Outputs:
ClientId:
Type: String
ValueSelector: 'Clients.Client[].ClientId'
InstanceId:
Type: String
ValueSelector: 'Clients.Client[].InstanceId'
- Name: RestoreBuckup
Action: 'ACS::HBR::RestoreHanaDatabaseBackup'
OnError: getExecutionFaildMessage
Description:
en: Restores and verifies the backup.
Properties:
vaultId: '{{ vaultId }}'
sourceClusterId: '{{ sourceClusterId }}'
sourceSystemName:
'Fn::Select':
- 0
- 'Fn::Split':
- ':'
- '{{ ACS::TaskLoopItem }}'
clusterId: '{{ destinationClusterId }}'
databaseName:
'Fn::Select':
- 1
- 'Fn::Split':
- ':'
- '{{ ACS::TaskLoopItem }}'
HANAInstanceServerId: '{{ checkForActivateClient.InstanceId }}'
HANASID: '{{ HANASID }}'
masterClientId: '{{ checkForActivateClient.ClientId }}'
Loop:
Items: '{{ databaseName }}'
RateControl:
MaxErrors: 0
Mode: Concurrency
Concurrency: 1
- Name: runCommand
Action: 'ACS::ECS::RunCommand'
OnSuccess: DingTalkNotify
OnError: getExecutionFaildMessage
Description:
en: Verifies the running status of the SAP HANA instance.
Properties:
regionId: '{{ ACS::RegionId }}'
commandContent:
'Fn::Join':
- ''
- - 'su - '
- 'Fn::Jq':
- First
- .key | ascii_downcase
- key: '{{ HANASID }}'
- 'adm -c "sapcontrol -nr '
- '{{ HANAInstanceNumber }}'
- ' -function GetProcessList"; if [[ $? -eq 3 ]]; then exit 0;fi'
instanceId: '{{ checkForActivateClient.InstanceId }}'
commandType: RunShellScript
timeout: '180'
Outputs:
commandOutputs:
Type: String
ValueSelector: invocationOutput
- Name: getExecutionFaildMessage
Action: 'ACS::ExecuteAPI'
Description:
en: Gets the execution failure message.
Properties:
Service: OOS
API: ListExecutions
Parameters:
ExecutionId: '{{ ACS::ExecutionId }}'
Outputs:
statusMessage:
Type: String
ValueSelector: 'Executions[].StatusMessage'
- Name: DingTalkNotifyExecutionFailed
Action: 'ACS::Notify'
OnSuccess: 'ACS::END'
Description:
en: Sends a notification about the execution failure.
Properties:
NotifyType: WebHook
WebHook:
URI: '{{ dingTalkWebhook }}'
Headers:
Content-Type: application/json
Content:
msgtype: markdown
markdown:
title: '{{ ACS::CurrentUTCTime }}-HBR automated test failure report'
text:
'Fn::Join':
- |+
- - '#### {{ ACS::CurrentUTCTime }} - HBR automated test failure report'
- 'Database checked: {{ databaseName }}'
- 'Error message: {{ getExecutionFaildMessage.statusMessage }}'
- '**For details, go to the [OOS console](https://oos.console.alibabacloud.com/{{ ACS::RegionId }}/execution/detail/{{ ACS::ExecutionId }})**'
at:
atMobiles: []
isAtAll: true
- Name: DingTalkNotify
Action: 'ACS::Notify'
Description:
en: Sends a notification with the test results.
Properties:
NotifyType: WebHook
WebHook:
URI: '{{ dingTalkWebhook }}'
Headers:
Content-Type: application/json
Content:
msgtype: markdown
markdown:
title: '{{ ACS::CurrentUTCTime }}-HBR automated test report'
text:
'Fn::Join':
- |+
- - '#### {{ ACS::CurrentUTCTime }} - HBR automated test report'
- 'Test result: SUCCESS'
- 'Database checked: {{ databaseName }}'
- 'Destination instance: {{ ECSHostname }}'
- 'Destination instance ID: {{ checkForActivateClient.InstanceId }}'
- '**For more information, go to the [OOS console](https://oos.console.alibabacloud.com/{{ACS::RegionId}}/execution/detail/{{ ACS::ExecutionId }})**'
at:
atMobiles: []
isAtAll: true