全部產品
Search
文件中心

CloudOps Orchestration Service:ACS-HBR-SAPHanaRestorationAutomationByExistingECS

更新時間:Sep 06, 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

字串校正Regex : ^[A-Z][A-Z0-9][A-Z0-9]$

ECSHostname

目的執行個體主機名稱

String

字串校正Regex : ^([a-zA-Z0-9]

HANAInstanceNumber

目的執行個體SAP HANA執行個體編號

String

字串校正Regex : ^([0-8][0-9]

dingTalkWebhook

DingTalk機器人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: DingTalk機器人Webhook地址
      en: DingTalk Robot Webhook
    Description:
      zh-cn: 'DingTalk自訂機器人Webhook地址,用以向DingTalk發送測試結果訊息和刪除雲資源審批訊息,更多請瀏覽<a href=''https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq'' target=''_blank''>DingTalk自訂機器人</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 HANADatabase Backup設定
      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: DingTalk通知測試結果
    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