全部产品
Search
文档中心

系统运维管理:ACS-HBR-SAPHanaRestorationAutomationByExistingECS

更新时间:Sep 05, 2024

ACS-HBR-SAPHanaRestorationAutomationByExistingECS SAP HANA备份可用性验证(恢复到已有实例)

模板描述

在已有的两台SAP HANA实例(源实例和目的实例),通过HBR服务将源实例备份数据恢复到目的实例,并检查恢复后的目的实例状态立即执行

模板类型

自动化

所有者

Alibaba Cloud

输入参数

参数名称

描述

类型

是否必填

默认值

约束

vaultId

HBR备份库ID

String

sourceClusterId

HBR源实例Id

String

destinationClusterId

HBR目的实例Id

String

HANASID

目的实例SAP HANA SID

String

字符串校验正则表达式 : ^[A-Z][A-Z0-9][A-Z0-9]$

ECSHostname

目的实例主机名

String

字符串校验正则表达式 : ^([a-zA-Z0-9]

HANAInstanceNumber

目的实例SAP HANA实例编号

String

字符串校验正则表达式 : ^([0-8][0-9]

dingTalkWebhook

钉钉机器人Webhook地址

String

databaseName

数据库实例列表

List

['SYSTEMDB@:SYSTEMDB']

输出参数

执行此模板需要的权限策略

{
    "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"
        }
    ]
}

详情

ACS-HBR-SAPHanaRestorationAutomationByExistingECS详情

模板内容

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.'
  zh-cn: 在已有的两台SAP HANA实例(源实例和目的实例),通过HBR服务将源实例备份数据恢复到目的实例,并检查恢复后的目的实例状态
  name-en: ACS-HBR-SAPHanaRestorationAutomationByExistingECS
  name-zh-cn: SAP HANA备份可用性验证(恢复到已有实例)
Parameters:
  vaultId:
    Label:
      zh-cn: HBR备份库ID
      en: Backup Vault ID
    Description:
      zh-cn: 备份库的Id
      en: Backup vault ID
    Type: String
  sourceClusterId:
    Label:
      zh-cn: HBR源实例Id
      en: Source SAP HANA instance ID
    Description:
      zh-cn: '源实例Id, 需要恢复的SAP HANA备份实例的Id,请在云备份控制台-ECS应用备份-实例名称/Id一栏查看。'
      en: 'Source SAP HANA instance ID, can be found in the Cloud Backup Console - ECS Application Backup - Instance Name/ID.'
    Type: String
  destinationClusterId:
    Label:
      zh-cn: HBR目的实例Id
      en: Destination SAP HANA instance ID
    Description:
      zh-cn: '目的实例Id, 测试的SAP HANA备份的实例Id,请在云备份控制台-ECS应用备份-实例名称/Id一栏查看。'
      en: 'Destination SAP HANA instance ID, can be found in the Cloud Backup Console - ECS Application Backup - Instance Name/ID.'
    Type: String
  databaseName:
    Label:
      zh-cn: 数据库实例列表
      en: SAP HANA Database List
    Description:
      zh-cn: 需要恢复备份的SAP HANA数据库实例列表,格式:<源数据库名>@<SID>:<目的数据库名>,多个数据库实例请以换行分隔
      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:
      zh-cn: '必须输入3个字符,可包含大写字母或数字,首位必须是大写字母。'
      en: '3 characters,can including capital letter or number, must starting with capital letter.'
    Label:
      zh-cn: 目的实例SAP HANA SID
      en: SAP HANA  SID
    Description:
      zh-cn: 目的实例SAP HANA SID
      en: Destination instance SAP HANA SID
    AllowedPattern: '^[A-Z][A-Z0-9][A-Z0-9]$'
  ECSHostname:
    Type: String
    Label:
      zh-cn: 目的实例主机名
      en: Hostname
    Description:
      zh-cn: 目的实例主机名
      en: SAP HANA ECS hostname
    AllowedPattern: '^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-])*([a-zA-Z0-9])$'
    ConstraintDescription:
      zh-cn: 长度为 2-13 个字符,允许使用大小写字母、数字或连字符(-),但不能以连字符(-)开头或结尾
      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:
      zh-cn: 目的实例SAP HANA实例编号
      en: SAP HANA Instance Number
    Description:
      zh-cn: 目的实例SAP HANA实例编号
      en: SAP HANA instance number
    ConstraintDescription:
      zh-cn: 2位数字,00-97
      en: '2 numbers,00-97.'
    AllowedPattern: '^([0-8][0-9]|9[0-6])$'
  dingTalkWebhook:
    Label:
      zh-cn: 钉钉机器人Webhook地址
      en: DingTalk Robot Webhook
    Description:
      zh-cn: '钉钉自定义机器人Webhook地址,用以向钉钉发送测试结果消息和删除云资源审批消息,更多请浏览<a href=''https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq'' target=''_blank''>钉钉自定义机器人</a>。'
      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:
      zh-cn: 查询源实例SAP HANA数据库备份设置
      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:
      zh-cn: 检查客户端是否为激活状态
      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:
      zh-cn: 恢复并验证备份
      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
      zh-cn: 校验SAP HANA实例运行状态
    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
      zh-cn: 获取执行失败信息
    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
      zh-cn: 通知执行失败消息
    Properties:
      NotifyType: WebHook
      WebHook:
        URI: '{{ dingTalkWebhook }}'
        Headers:
          Content-Type: application/json
        Content:
          msgtype: markdown
          markdown:
            title: '{{ ACS::CurrentUTCTime }}-HBR自动测试执行失败报告'
            text:
              'Fn::Join':
                - |+


                - - '#### {{ ACS::CurrentUTCTime }}-HBR自动测试执行失败报告'
                  - '检测数据库:{{ databaseName }}'
                  - '错误信息:{{ getExecutionFaildMessage.statusMessage }}'
                  - '**详情请到[OOS控制台](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
      zh-cn: 钉钉通知测试结果
    Properties:
      NotifyType: WebHook
      WebHook:
        URI: '{{ dingTalkWebhook }}'
        Headers:
          Content-Type: application/json
        Content:
          msgtype: markdown
          markdown:
            title: '{{ ACS::CurrentUTCTime }}-HBR自动测试报告'
            text:
              'Fn::Join':
                - |+


                - - '#### {{ ACS::CurrentUTCTime }}-HBR自动测试报告'
                  - 测试结果:SUCCESS
                  - '检测数据库:{{ databaseName }}'
                  - '目的实例:{{ ECSHostname }}'
                  - '目的实例Id:{{ checkForActivateClient.InstanceId }}'
                  - '**详细信息请到[OOS控制台](https://oos.console.aliyun.com/{{ACS::RegionId}}/execution/detail/{{ ACS::ExecutionId }})查看**'
          at:
            atMobiles: []
            isAtAll: true