設備管理控制台中的自訂指令碼

定義執行預先清除作業的 LiveClone 備份和災難復原工作流程時,您可以選取 Optim 隱私權資料遮蓋或自訂指令碼。

如果是自訂指令碼,請至少指定一個前置或後置處理指令碼。

  • 視需要指定前置指令碼。前置指令碼用於在掛接或卸載應用程式前設定環境。這個指令碼必須位於伺服器上名為 /act/scripts 的資料夾中,該伺服器會代管已掛接的備份。
  • 在對應的「逾時時間 (秒)」中,指定腳本完成所需的時間。
  • 視需要指定附註。用於在資料掛接或卸載後對資料執行作業的後置指令碼。這個指令碼必須位於伺服器上名為 /act/scripts 的資料夾中,該伺服器會代管已掛接的備份。
  • 在對應的「逾時時間 (秒)」中,指定腳本完成所需的時間。

備份和災難復原工作流程前後指令碼

備份和災難復原工作流程會根據排程或需求掛接及卸載備份。在備份和災難復原工作流程中,您可以呼叫下列項目:

  • 在掛接或卸載備份前執行的前置指令碼
  • 備份掛接或卸載後執行的後置指令碼

您可以在掛接或卸載資料前後執行指令碼,藉此完成下列操作:

  • 清除私密/機密資訊
  • 產生報表
  • 倉儲資料,特別是擷取、轉換及載入 (ETL) 作業

指令碼必須位於代管已掛接的備份和災難復原工作流程備份的伺服器上名為 /act/scripts 的資料夾中。

環境變數

環境變數可讓您叫用適用於特定工作、工作類型或應用程式的指令。環境變數會以 ACT_ 為前置字元。舉例來說,資料庫的環境變數可能如下所示:

    [$ACT_APPNAME =="productiondb"]

或掛接作業的環境變數可能如下所示:

    [$ACT_JOBTYPE == "mount"]

以下列出常見的環境變數和範例值:

  • JOBNAME:工作名稱,例如 Job_0123456。
  • APPID:應用程式的 ID,例如 4186。
  • APPNAME:應用程式名稱,例如 My-DB。
  • HOSTNAME:主機名稱,也就是這項工作的目標,例如 Jupiter。
  • SOURCEHOST:這個應用程式的來源主機名稱,例如 Saturn。
  • JOBTYPE:工作類別的文字版本,例如掛接或卸載。
  • PHASE:描述工作階段的文字字串,例如前置或後置。
  • TIMEOUT:定義指令碼的執行時間長度。
  • 選項:適用於這項工作的政策選項。

範例指令碼

下列指令碼範例使用三個環境變數:

  • ACT_JOBTYPE:識別作業是掛接或卸載作業。
  • ACT_PHASE:識別階段是前置還是後置。
  • 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 $?
    ```