Skip to main content
  • Place orders quickly and easily
  • View orders and track your shipping status
  • Enjoy members-only rewards and discounts
  • Create and access a list of your products
  • Manage your Dell EMC sites, products, and product-level contacts using Company Administration.

PowerProtect Data Manager 19.16 File System User Guide

Content requirements for pre-scripts and post-scripts

The pre-script and post-script content must be in text format with a maximum size of 20 KB. The maximum number of scripts that a PowerProtect Data Manager server supports is 10,000. A maximum of one pre-script and one post-script can run with a backup on Linux, UNIX, or Windows.

Each script must return the exit code 0 to indicate success. Other exit codes can depend on the particular script and environment. Ensure that the exit codes and corresponding message strings (if available) are logged in the log file.

For example, the following pre-script on Windows stops a service and checks for the error level. The error level 1 indicates an invalid command, an inability to find a file or pathname, or an inability to access a resource.

@echo off
net stop service
if ERRORLEVEL 1 goto error
exit
:error
echo An issue occurred with the pre-script.

The following sample post-script on Windows starts a service and checks for the error level.

@echo off
net start service
if ERRORLEVEL 1 goto error
exit
:error
echo An issue occurred with the post-script.

The pre-scripts and post-scripts can also perform operations according to the input parameters that are specified for the scripts. The following examples show the use of input parameters with a pre-script and post-script.

Parameters used with a pre-script

The following parameters are provided in this order to a pre-script that runs on an Oracle RMAN agent host on Linux:

  1. Script Name—Specifies the name of the pre-script—Example: pre_script_stop_database_45362.sh
  2. Operation Type—Specifies the type of operation performed—Example: backup
  3. Job ID—Specifies the agent service session ID—Example: 45362
  4. Backup Level—Specifies the level of backup—Example: log
  5. Asset Name—Specifies the name of the asset—Example: orcl2
  6. Policy name—Specifies the name of the protection policy—Example: test-oracle-plc
  7. OS type—Specifies the type of OS where the script is run—Example: Linux
  8. App Type—Specifies the application type—Example: ORACLE_DATABASE

The following sample pre-script uses the provided parameters to stop an Oracle database on Linux:

#!/bin/bash
# Input parameters
script_name=$1
operation_type=$2
job_id=$3
backup_level=$4
asset_name=$5
policy_name=$6
os_type=$7
app_type=$8

# Check if the OS type is Linux
if [[ "$os_type" == "Linux" ]]; then
    # Check if the Oracle database is running
    if pgrep -x $asset_name > /dev/null; then
        echo "The Oracle database is running. Stopping the database."
        # Stop the Oracle database
        sudo systemctl stop $asset_name
        echo "The Oracle database has been stopped."
    else
        echo "The Oracle database is not running."
    fi
else
    echo "This script only works on Linux."
fi

The following sample pre-script uses the provided parameters to start an Oracle backup on Linux:

#!/bin/bash
script_name=$1
operation_type=$2
job_id=$3
backup_level=$4
asset_name=$5
policy_name=$6
os_type=$7
app_type=$8

orauser="oracle"
orahome="/u01/app/oracle/product/12.1.0/dbhome_1"
su - ${orauser} << BOF 2>&1
export ORACLE_SID=$5
export ORACLE_HOME=$orahome
$orahome/bin/sqlplus /nolog << EOF 2>&1
connect / as sysdba
alter database begin backup;
exit;
EOF
BOF

Parameters used with a post-script

The following parameters are provided in this order to a post-script that runs on an Oracle RMAN agent host on Linux:

  1. Script Name—Specifies the name of the post-script—Example: post_script_start_database_45362.sh
  2. Operation Type—Specifies the type of operation performed—Example: backup
  3. Job ID—Specifies the agent service session ID—Example: 45362
  4. Backup Level—Specifies the level of backup—Example: log
  5. Asset Name—Specifies the name of the asset—Example: orcl2
  6. Policy name—Specifies the name of the protection policy—Example: test-oracle-plc
  7. Operating system type—Specifies the type of OS where the script is run—Example: Linux
  8. App Type—Specifies the application type—Example: ORACLE_DATABASE
  9. Job Status—Specifies the status (SUCCESS or FAILURE) of the protection job—Example: SUCCESS
  10. Pre Script Status—Specifies the status (0, 1, -1) of the pre-script job—Example: 0

The following sample post-script uses the provided parameters to start an Oracle database on Linux:

#!/bin/bash
# Input parameters
script_name=$1
operation_type=$2
job_id=$3
backup_level=$4
asset_name=$5
policy_name=$6
os_type=$7
app_type=$8
job_status_code=$9
pre_script_status_code=${10}

# Check if the OS type is Linux
if [[ "$os_type" == "Linux" ]]; then
    if pgrep -x $asset_name > /dev/null; then
        echo "The Oracle database is running."
    else
        echo "The Oracle database is not running."
        # Check if pre-script status is 0
        if [[ "$pre_script_status_code" == "0" ]]; then
            # Start the Oracle database
            sudo systemctl start $asset_name
            echo "The Oracle database has been started."
        else
            echo "The Oracle database cannot be started as the pre-script status code is not 0."
        fi
    fi
else
    echo "This script only works on Linux."
fi

The following sample post-script uses the provided parameters to stop an Oracle backup on Linux:

#!/bin/bash
script_name=$1
operation_type=$2
job_id=$3
backup_level=$4
asset_name=$5
policy_name=$6
os_type=$7
app_type=$8

orauser="oracle"
orahome="/u01/app/oracle/product/12.1.0/dbhome_1"
su - ${orauser} << BOF 2>&1
export ORACLE_SID=$5
export ORACLE_HOME=$orahome
$orahome/bin/sqlplus /nolog << EOF 2>&1
connect / as sysdba
alter database end backup;
exit;
EOF
BOF

Rate this content

Accurate
Useful
Easy to understand
Was this article helpful?
0/3000 characters
  Please provide ratings (1-5 stars).
  Please provide ratings (1-5 stars).
  Please provide ratings (1-5 stars).
  Please select whether the article was helpful or not.
  Comments cannot contain these special characters: <>()\