在定义执行预清理的 LiveClone Backup and DR 工作流时,您可以从 Optim 隐私数据遮盖或自定义脚本中进行选择。
对于自定义脚本,请至少指定一个预处理或后处理脚本。
- 根据需要指定预脚本。预脚本用于在挂载或卸载应用之前配置环境。此脚本必须位于托管已挂载备份的服务器上的名为
/act/scripts的文件夹中。 - 在对应的超时时间(以秒为单位)中,指定脚本完成所需的时间 。
- 根据需要指定后脚本。后脚本用于在数据挂载或卸载后对数据执行操作。此脚本必须位于托管已挂载备份的服务器上的名为
/act/scripts的文件夹中。 - 在对应的超时时间(以秒为单位)中,指定脚本完成所需的时间 。
Backup and DR 工作流预脚本和后脚本
Backup and DR 工作流会根据时间表或按需挂载和卸载备份。在 Backup and DR 工作流中,您可以调用以下内容:
- 在挂载或卸载备份之前运行的预脚本
- 在挂载或卸载备份之后运行的后脚本
能够在挂载或卸载数据之前和之后运行脚本,让您可以执行以下操作:
- 清理敏感信息
- 生成报告
- 仓储数据,尤其是提取、转换和加载 (ETL) 操作
脚本必须位于托管已挂载 Backup and DR 工作流备份的服务器上的名为 /act/scripts 的文件夹中。
环境变量
借助环境变量,您可以调用适用于特定作业、作业类型或应用的命令。环境变量以 ACT_ 为前缀。例如,数据库的环境变量可能如下所示:
[$ACT_APPNAME =="productiondb"]
或者,挂载操作的环境变量可能如下所示:
[$ACT_JOBTYPE == "mount"]
以下是常见环境变量的列表,其中包含示例值:
- JOBNAME:作业的名称,例如 Job_0123456。
- APPID:应用的 ID,例如 4186。
- APPNAME:应用的名称,例如 My-DB。
- HOSTNAME:此作业的目标主机的名称,例如 Jupiter。
- SOURCEHOST:此应用的来源主机的名称,例如 Saturn。
- JOBTYPE:作业类的文本版本,例如 mount 或 unmount。
- PHASE:描述作业阶段的文本字符串,例如 pre 或 post。
- TIMEOUT:定义脚本的持续时间,即允许脚本 运行的时间。
- OPTIONS:适用于此作业的政策选项。
示例脚本
以下脚本示例使用了三个环境变量:
- ACT_JOBTYPE:标识作业是挂载 还是卸载操作。
- ACT_PHASE:标识阶段是 pre 还是 post。
ACT_MULTI_END:仅在同时挂载数据库及其 日志时使用。如果此值为 true,则数据库处于可访问状态。
```sh #!/bin/sh set +x echo "*** Running user script: Job - $ACT_JOBNAME Type - $ACT_JOBTYPE Phase - $ACT_PHASE***" #Use the first if clause to perform application specific operations during mount and in this example scrub-mount operation. #Use the second if clause to perform any application specific operation during unmount and in this example, #scrub-unmount operation. #if [[ $ACT_JOBTYPE == "mount" ]] || [[ $ACT_JOBTYPE == "scrub-mount" ]]; then if [[ $ACT_JOBTYPE == "unmount" ]] || [[ $ACT_JOBTYPE == "scrub-unmount" ]]; then echo "NO-OP for job type $ACT_JOBTYPE" exit 0 fi #Use the first if clause to perform application specific operations during the pre phase. #Use the second if clause to perform application specific operations during the post phase. #if [[ $ACT_PHASE == "post" ]]; then if [[ $ACT_PHASE == "pre" ]]; then echo "NO-OP for phase $ACT_PHASE" exit 0 fi #For multi-phase jobs (database and logs) check if the database has been mounted and the logs applied then #skip logs. #If the operation needs to be performed in phases other than the last phase, modify the clause. if [[ -z "$ACT_MULTI_END" ]] && [[ $ACT_MULTI_END != "true" ]]; then echo "NO-OP for multi-phase operation" exit 0 fi cd /act/scripts echo "**** Running application specific logic: Job - $ACT_JOBNAME Type - $ACT_JOBTYPE Phase - $ACT_PHASE *" Any application specific commands will go here echo "** Finished running application specific logic : Job - $ACT_JOBNAME Type - $ACT_JOBTYPE Phase - $ACT_PHASE*" exit $? ```