Template name
ACS-HBR-SAPHanaRestorationAutomationByExistingECS
Template description
Uses the Hybrid Backup Recovery (HBR) service to restore the backup data from the source SAP HANA instance to the destination SAP HANA instance and checks the status of the destination instance.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
vaultId | The ID of the 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 SID of the destination SAP HANA instance. | String | Yes | Regular expression for string verification: ^[A-Z][A-Z0-9][A-Z0-9]$ | |
ECSHostname | The name of the host to which the destination instance belongs. | String | Yes | Regular expression for string verification: ^([a-zA-Z0-9] | |
HANAInstanceNumber | The number of the destination SAP HANA instance. | String | Yes | Regular expression for string verification: ^([0-8][0-9] | |
dingTalkWebhook | The webhook URL of the DingTalk chatbot. | String | Yes | ||
databaseName | The database instances. | List | No | ['SYSTEMDB@:SYSTEMDB'] |
Output parameters
None
Permission policy that is required to execute the template
{
"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"
}
]
}
References
For more information, see ACS-HBR-SAPHanaRestorationAutomationByExistingECS.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: 'This template uses existing SAP HANA instances(source instance and destination instance) to restore the source instance backup data to the destination instance through the HBR service, and check the restored destination instance status.'
name-en: ACS-HBR-SAPHanaRestorationAutomationByExistingECS
Parameters:
vaultId:
Label:
en: Backup Vault ID
Description:
en: Backup vault ID
Type: String
sourceClusterId:
Label:
en: Source SAP HANA instance ID
Description:
en: 'Source SAP HANA instance ID, can be found in the Cloud Backup Console - ECS Application Backup - Instance Name/ID.'
Type: String
destinationClusterId:
Label:
en: Destination SAP HANA instance ID
Description:
en: 'Destination SAP HANA instance ID, can be found in the Cloud Backup Console - ECS Application Backup - Instance Name/ID.'
Type: String
databaseName:
Label:
en: SAP HANA Database List
Description:
en: SAP HANA database list in format of "<Source SAP HANA database name>@<Source SAP HANA system Id>". Separate multiple SAP HANA database with line breaks
Type: List
Default:
- 'SYSTEMDB@<SID>:SYSTEMDB'
HANASID:
Type: String
ConstraintDescription:
en: '3 characters,can including capital letter or number, must starting with capital letter.'
Label:
en: SAP HANA SID
Description:
en: Destination instance SAP HANA SID
AllowedPattern: '^[A-Z][A-Z0-9][A-Z0-9]$'
ECSHostname:
Type: String
Label:
en: Hostname
Description:
en: SAP HANA ECS hostname
AllowedPattern: '^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-])*([a-zA-Z0-9])$'
ConstraintDescription:
en: 'The length is 2-13 characters,can starting with a capital or lowercase letter,and can contain numbers,or -,but can''t starting with - or end with -.'
HANAInstanceNumber:
Type: String
Label:
en: SAP HANA Instance Number
Description:
en: SAP HANA instance number
ConstraintDescription:
en: '2 numbers,00-97.'
AllowedPattern: '^([0-8][0-9]|9[0-6])$'
dingTalkWebhook:
Label:
en: DingTalk Robot Webhook
Description:
en: 'Sends notification to DingTalk via webhook for asking approval. The execution remains paused until approved or rejected. Please refer https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq for details.'
Type: String
Tasks:
- Name: checkHanaBackupSetting
Action: 'ACS::CheckFor'
Description:
en: Check source SAP HANA backup settings
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: Check for client status(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: Restore and verify 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: Verify 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: Get execution failure information
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: Notification execution failure message
Properties:
NotifyType: WebHook
WebHook:
URI: '{{ dingTalkWebhook }}'
Headers:
Content-Type: application/json
Content:
msgtype: markdown
markdown:
title: '{{ ACS::CurrentUTCTime }}-HBR test failure report'
text:
'Fn::Join':
- |+
-- '#### {{ ACS::CurrentUTCTime }}-HBR test failure report'
- 'Check a database:{{ databaseName }}'
- 'Error message:{{ getExecutionFaildMessage.statusMessage }}'
- '**For more information, go to the [OOS console](https://oos.console.aliyun.com/{{ ACS::RegionId }}/execution/detail/{{ ACS::ExecutionId }})**'
at:
atMobiles: []
isAtAll: true
- Name: DingTalkNotify
Action: 'ACS::Notify'
Description:
en: Notify test results
Properties:
NotifyType: WebHook
WebHook:
URI: '{{ dingTalkWebhook }}'
Headers:
Content-Type: application/json
Content:
msgtype: markdown
markdown:
title: '{{ ACS::CurrentUTCTime }}-HBR test report'
text:
'Fn::Join':
- |+
-- '#### {{ ACS::CurrentUTCTime }}-HBR test report'
- Test result:SUCCESS
- 'Check a database:{{ databaseName }}'
- 'Destination instance:{{ ECSHostname }}'
- 'ID of the destination instance:{{ checkForActivateClient.InstanceId }}'
- '**For more information, go to the [OOS console](https://oos.console.aliyun.com/{{ ACS::RegionId }}/execution/detail/{{ ACS::ExecutionId }})**'
at:
atMobiles: []
isAtAll: true