-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS-HBR-SAPHanaRestorationAutomationByExistingECS.yml
267 lines (263 loc) · 9.63 KB
/
ACS-HBR-SAPHanaRestorationAutomationByExistingECS.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
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 Hybrid Backup Recovery 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 Hybrid Backup Recovery 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