Skip to main content
Template scripts for configuring OEM
Updated over 6 months ago

Druva provides template scripts that you can use to back up databases on the Oracle RMAN Database host. The scripts are listed as follows:

The scripts, oracle_oem_full_backup.txt and oracle_oem_archivelog_backup.txt are used on the OEM console while configuring the backup job from the OEM Job Engine.

oracle_oem_full_backup.txt

This script performs a full backup of the databases on the Oracle RMAN Database host. You may use your own RMAN block, provided that you do not change the ${RMANBACKUP_MOUNTPOINT_FULL} variable. The value of this variable indicates the path on the Oracle RMAN Database host, which is mounted on the Phoenix Backup Store. This path is critical as the backups are performed on the Phoenix Backup Store’s mount point.

001#Update ORACLE_SID for the database. Example: ORACLE_SID=PROD002export ORACLE_SID=<>003#Update ORACLE_BASE for your database host server. E.g. ORACLE_BASE=/u01/app/oracle004export ORACLE_BASE=<>005#Update ORACLE_HOME for the database. Example: ORACLE_HOME=/opt/oracle/product/18c/dbhome_1006export ORACLE_HOME=<>007#Update PBS IP inside the quotes. Example: BACKUP_STORE_IP="172.xx.xx.xx"008export BACKUP_STORE_IP="<>"009#Update PBS Backup Mount name inside the quotes. Example: BACKUP_MOUNT="PRODMount"010export BACKUP_MOUNT="<>"011echo "Pre-Script execution is getting started"012if [[ -z "${ORACLE_HOME}" ]];013then014echo "Environment variable ORACLE_HOME not set... exiting"015exit 1016fi017if [[ -z "${ORACLE_SID}" ]];018then019echo "Environment variable ORACLE_SID not set... exiting"020exit 1021fi022SID=${ORACLE_SID}023echo "Validating backup request"024validate_resp=$(curl -X GET http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/1.2/backup 2> /dev/null)025if [ $? -ne 0 ];026then027echo "Request to validate phoenix backup failed... exiting"028echo "Response from Phoenix Backup Store: "$validate_resp029exit 1030fi031VALIDATE_ERROR_CODE=$(echo $validate_resp|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1)032if [ $VALIDATE_ERROR_CODE -ne 0 ];033then034echo "Response from Phoenix Backup Store: "$validate_resp035echo "Request to validate Phoenix backup failed... exiting"036exit 1037fi038# Sample output format039# {"error_code":0,"error_msg":"","result":{"is_reached_max_snapshots":false,"mount_name":"m2"}}040export IS_REACHED_MAX_SNAPSHOTS=$(echo $validate_resp|awk -F "is_reached_max_snapshots" '{print $2}'|cut -d ',' -f1 |cut -d ':' -f2)041if [ $IS_REACHED_MAX_SNAPSHOTS == "false" ];042then043echo "Validation for phoenix backup succeeded"044else045echo "Response from Phoenix Backup Store: "$validate_resp046echo "Validation for phoenix backup failed... exiting"047exit 1048fi049echo "Notifying Phoenix to start backup - Phoenix Backup Store=$BACKUP_STORE_IP mount name=$BACKUP_MOUNT"050export res=$(curl -X POST http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/backup 2> /dev/null)051if [ $? -ne 0 ];052then053echo "Request to start phoenix backup failed... exiting"054echo "Response from Phoenix Backup Store: "$res055exit 1056fi057# Sample output format058# {"error_code":4295622665,"error_msg":"Backup mount does not exist on Export Service.","result":{"mount_name":"mount4","mount_path":""}}059ERROR_CODE=$(echo $res|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1)060if [ $ERROR_CODE -ne 0 ];061then062echo "Response from Phoenix Backup Store: "$res063echo "Request to start Phoenix backup failed... exiting"064exit 1065fi066export REMOTE_MOUNTPOINT=$BACKUP_STORE_IP:$(echo $res|awk -F "mount_path" '{print $2}'|cut -d '"' -f3)067export RMANBACKUP_MOUNTPOINT=$(grep "^$REMOTE_MOUNTPOINT" /etc/fstab| sed 's/\s\+/ /g' |cut -d ' ' -f2)068if [ -z "$RMANBACKUP_MOUNTPOINT" ];069then070echo "Entry for Phoenix Backup Store mount not found in /etc/fstab... exiting"071exit 1072fi073export ACTUAL_MOUNTPOINT=$(mount|grep "^$REMOTE_MOUNTPOINT"|sed 's/\s\+/ /g' |cut -d " " -f3 2> /dev/null)074if [ -z "$ACTUAL_MOUNTPOINT" ];075then076mount $RMANBACKUP_MOUNTPOINT 2> /dev/null077if [ $? -ne 0 ];078then079     echo "Unable to mount $RMANBACKUP_MOUNTPOINT... exiting"080     exit 1081fi082else083export RMANBACKUP_MOUNTPOIN=$ACTUAL_MOUNTPOINT084fi085export PATH=$ORACLE_HOME/bin:$PATH086echo "Creating Dir $RMANBACKUP_MOUNTPOINT/$SID'/full'"087if [ ! -e $RMANBACKUP_MOUNTPOINT/$SID'/full' ]088then089mkdir -p $RMANBACKUP_MOUNTPOINT/$SID'/full'090if [ $? -eq 0 ];091then092     echo "Created directory for full backup $RMANBACKUP_MOUNTPOINT/$SID/full"093else094     echo "Oracle user does not have permission for $RMANBACKUP_MOUNTPOINT directory... exiting"095     exit 1096fi097elif [ ! -d $RMANBACKUP_MOUNTPOINT/${SID}'/full' ];098then099echo "$RMANBACKUP_MOUNTPOINT is not a directory... exiting"100exit 1101fi102#Creating Archivelog Directory103if [ ! -e $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs' ]104then105mkdir -p $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs'106if [ $? -eq 0 ];107then108     echo "Created directory for archivelogs backup $RMANBACKUP_MOUNTPOINT/$SID/archivelogs"109else110     echo "Oracle user does not have permission for $RMANBACKUP_MOUNTPOINT directory... exiting"111     exit 1112fi113elif [ ! -d $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs' ];114then115echo "$RMANBACKUP_MOUNTPOINT is not a directory... exiting"116exit 1117fi118 119export LOG_FILE_DIR=$RMANBACKUP_MOUNTPOINT/'_workspace/RMAN_Logs'120echo "Creating Log File Dir: =$RMANBACKUP_MOUNTPOINT'/_workspace/RMAN_Logs'"121if [ ! -e $LOG_FILE_DIR ]122then123mkdir -p $LOG_FILE_DIR124if [ $? -eq 0 ];125then126     echo "Created log directory for oracle backup $LOG_FILE_DIR"127else128     echo "Oracle user does not have permission for $LOG_FILE_DIR directory... exiting"129     exit 1130fi131fi132RMANBACKUP_MOUNTPOINT_FULL=$RMANBACKUP_MOUNTPOINT/$SID133echo -n >$LOG_FILE_DIR'/rman_full_backup.log'134touch $RMANBACKUP_MOUNTPOINT/_workspace/135if [ $? -ne 0 ];136then137echo "$RMANBACKUP_MOUNTPOINT directory is not writable.. exiting"138exit 1139fi140#Checking if any .lock file is present and deleting the same if the PID is NOT running.141export is_lock_file_present=`find ${RMANBACKUP_MOUNTPOINT} -type f -name ".RMAN_FULL_lock_*"|wc -l `142if [[ ${is_lock_file_present} -ne 0 ]]143then144     for _lock_file in `find ${RMANBACKUP_MOUNTPOINT} -type f -name ".RMAN_FULL_lock_*" | xargs `145     do146             export _pid=`echo ${_lock_file}|cut -d"_" -f4`147             export is_pid_proc_running=`ps -ef|grep ${_pid}|grep -v grep | wc -l`148             if [[ ${is_pid_proc_running} -ne 0 ]]149             then150                     echo "[INFO] Full backup Lock File: ${_lock_file} is present and PID is active"151                     echo "[ERROR] One Full backup is already in progress with process ${_pid}. Exiting current backup"152                     exit 1153             else154                     echo "[INFO] Full backup Lock File: ${_lock_file} is present and PID is NOT active"155                     echo "Deleting ${_lock_file}"156                     rm ${_lock_file}157                     if [ -e ${_lock_file} ]158                     then159                             echo "ERROR deleting file ${_lock_file}"160                     fi161             fi162     done163fi164# Creating a .lock file to represnt current active full/diff backup.165export file_stamp=`date | sed -e 's/ /_/g'`166export PID=`echo $$`167export LOCK_FILE=`echo ${RMANBACKUP_MOUNTPOINT}/.RMAN_FULL_lock_${PID}_${file_stamp}`168echo -n > ${LOCK_FILE}169if [ -e ${LOCK_FILE} ]170then171     echo "[INFO] Lock file created: ${LOCK_FILE}"172else173     echo "Error creating lock file: ${LOCK_FILE}"174     echo "[ERROR] Backup will now stop"175     exit 3176fi177#Calling Start RMAN Backup178export res_rmanbackup=$(curl -X POST http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/${SID}/full/rmanbackup 2> /dev/null)179if [ $? -ne 0 ];180then181echo "Request to start phoenix backup failed... exiting"182echo "Response from Phoenix Backup Store: "$res_rmanbackup183exit 1184fi185echo "Response RMAN Backup: ${res_rmanbackup}"186export SNAPSHOT_NAME=`echo $res_rmanbackup|awk -F "snap_name" '{print $2}'|cut -d '"' -f3`187if [ -z "$SNAPSHOT_NAME" ];188then189echo "Failed to get Snapshot name. Exiting. Please check Export Service Logs in PBS"190exit 1191fi192echo "Snapshot to be created ${SNAPSHOT_NAME}"193echo -n >$LOG_FILE_DIR'/rman_full_backup_'${SNAPSHOT_NAME}_${ORACLE_SID}'.log'194export RMAN_LOGFILE=$LOG_FILE_DIR'/rman_full_backup_'${SNAPSHOT_NAME}_${ORACLE_SID}'.log'195echo "RMAN Logfile: ${RMAN_LOGFILE}"196 197echo "Starting with RMAN backup. RMAN Log File: $RMAN_LOGFILE"198PARALLELISM=1199rman log=$RMAN_LOGFILE 2> /dev/null << EOF200connect target /201set echo on;202configure backup optimization on;203configure controlfile autobackup on;204configure device type disk parallelism $PARALLELISM BACKUP TYPE TO COPY;205configure datafile backup copies for device type disk to 1;206configure archivelog backup copies for device type disk to 1;207configure channel device type disk format '${RMANBACKUP_MOUNTPOINT_FULL}/full/datafile_%%U.bkp';208configure controlfile autobackup format for device type disk to '${RMANBACKUP_MOUNTPOINT_FULL}/full/full_controlfile_%%d_%%F.bkp';209run210{211sql 'alter system archive log current';212backup incremental level 1 for recover of copy with tag 'phoenix_oracle_backup' database;213recover copy of database with tag 'phoenix_oracle_backup';214sql 'alter system archive log current';215backup as backupset format '${RMANBACKUP_MOUNTPOINT_FULL}/archivelogs/%%d_%%h_%%e_%%s_%%t.arc' archivelog all not backed up;216#Force is to ignore I/O errors217delete noprompt obsolete device type disk;218delete force NOPROMPT expired copy;219delete force NOPROMPT expired backup;220crosscheck backup;221crosscheck copy;222}223configure backup optimization clear;224configure controlfile autobackup clear;225exit226EOF227export RMAN_EXIT_STATUS=$?228if [ $RMAN_EXIT_STATUS -ne 0 ];229then230echo ""231echo "rman failed with status $RMAN_EXIT_STATUS.. exiting"232rm ${LOCK_FILE}233if [ -e ${LOCK_FILE} ]234then235     echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}"236else237     dt=`date | sed -e 's/ /_/g'`238     echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} "239fi240exit 1241fi242 243echo "Triggering backup operation"244echo "Notifying Phoenix to upload RMAN Logs"245echo "RMAN log location: $LOG_FILE_DIR/rman_full_backup_${SNAPSHOT_NAME}_${ORACLE_SID}.log"246echo "Notifying Phoenix to upload RMAN Logs"247rman_uploadlog_res=$(curl -X POST -H "Content-Type: multipart/form-data" -F "file=@$LOG_FILE_DIR/rman_full_backup_${SNAPSHOT_NAME}_${ORACLE_SID}.log" -F mountpoint=$RMANBACKUP_MOUNTPOINT -F platform=linux http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/uploadlog 2> /dev/null)248if [ $? -ne 0 ];249then250echo "Request to send RMAN Logs failed..."251echo "Response from Phoenix Backup Store: "$rman_uploadlog_res252fi253rm ${LOCK_FILE}254if [ -e ${LOCK_FILE} ]255then256     echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}"257else258     dt=`date | sed -e 's/ /_/g'`259     echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} "260fi261echo "Notifying Phoenix to end backup"262export final_res=$(curl -X PUT http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/backup 2> /dev/null)263 264if [ $? -ne 0 ];265then266echo "Request to end phoenix backup failed... exiting"267echo "Response from Phoenix Backup Store: "$final_res268rm ${LOCK_FILE}269if [ -e ${LOCK_FILE} ]270then271     echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}"272else273     dt=`date | sed -e 's/ /_/g'`274     echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} "275fi276exit 5277fi278export ERROR_CODE=$(echo $final_res|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1)279if [ $ERROR_CODE -ne 0 ];280then281echo "Response from Phoenix Backup Store: "$res282echo "Request to start Phoenix backup failed... exiting"283exit 7284fi285echo $final_res286echo "Exiting with successful status"

oracle_oem_archivelog_backup.txt

001#Update ORACLE_SID for the database. Example: ORACLE_SID=PROD002export ORACLE_SID=<>003#Update ORACLE_BASE for your database host server. E.g. ORACLE_BASE=/u01/app/oracle004export ORACLE_BASE=<>005#Update ORACLE_HOME for the database. Example: ORACLE_HOME=/opt/oracle/product/18c/dbhome_1006export ORACLE_HOME=<>007#Update PBS IP inside the quotes. Example: BACKUP_STORE_IP="172.xx.xx.xx"008export BACKUP_STORE_IP="<>"009#Update PBS Backup Mount name inside the quotes. Example: BACKUP_MOUNT="PRODMount"010export BACKUP_MOUNT="<>"011echo "Pre-Script execution is getting started"012if [[ -z "${ORACLE_HOME}" ]];013then014    echo "Environment variable ORACLE_HOME not set... exiting"015    exit 1016fi017if [[ -z "${ORACLE_SID}" ]];018then019    echo "Environment variable ORACLE_SID not set... exiting"020    exit 1021fi022SID=${ORACLE_SID}023echo "Validating backup request"024validate_resp=$(curl -X GET http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/1.2/backup 2> /dev/null)025if [ $? -ne 0 ];026then027    echo "Request to validate phoenix backup failed... exiting"028    echo "Response from Phoenix Backup Store: "$validate_resp029    exit 1030fi031VALIDATE_ERROR_CODE=$(echo $validate_resp|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1)032if [ $VALIDATE_ERROR_CODE -ne 0 ];033then034    echo "Response from Phoenix Backup Store: "$validate_resp035    echo "Request to validate Phoenix backup failed... exiting"036    exit 1037fi038# Sample output format039# {"error_code":0,"error_msg":"","result":{"is_reached_max_snapshots":false,"mount_name":"m2"}}040export IS_REACHED_MAX_SNAPSHOTS=$(echo $validate_resp|awk -F "is_reached_max_snapshots" '{print $2}'|cut -d ',' -f1 |cut -d ':' -f2)041if [ $IS_REACHED_MAX_SNAPSHOTS == "false" ];042then043    echo "Validation for phoenix backup succeeded"044else045    echo "Response from Phoenix Backup Store: "$validate_resp046    echo "Validation for phoenix backup failed... exiting"047    exit 1048fi049echo "Notifying Phoenix to start backup - Phoenix Backup Store=$BACKUP_STORE_IP mount name=$BACKUP_MOUNT"050export res=$(curl -X POST http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/backup 2> /dev/null)051if [ $? -ne 0 ];052then053    echo "Request to start phoenix backup failed... exiting"054    echo "Response from Phoenix Backup Store: "$res055    exit 1056fi057# Sample output format058# {"error_code":4295622665,"error_msg":"Backup mount does not exist on Export Service.","result":{"mount_name":"mount4","mount_path":""}}059ERROR_CODE=$(echo $res|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1)060if [ $ERROR_CODE -ne 0 ];061then062    echo "Response from Phoenix Backup Store: "$res063    echo "Request to start Phoenix backup failed... exiting"064    exit 1065fi066export REMOTE_MOUNTPOINT=$BACKUP_STORE_IP:$(echo $res|awk -F "mount_path" '{print $2}'|cut -d '"' -f3)067export RMANBACKUP_MOUNTPOINT=$(grep "^$REMOTE_MOUNTPOINT" /etc/fstab| sed 's/\s\+/ /g' |cut -d ' ' -f2)068if [ -z "$RMANBACKUP_MOUNTPOINT" ];069then070    echo "Entry for Phoenix Backup Store mount not found in /etc/fstab... exiting"071    exit 1072fi073export ACTUAL_MOUNTPOINT=$(mount|grep "^$REMOTE_MOUNTPOINT"|sed 's/\s\+/ /g' |cut -d " " -f3 2> /dev/null)074if [ -z "$ACTUAL_MOUNTPOINT" ];075then076    mount $RMANBACKUP_MOUNTPOINT 2> /dev/null077    if [ $? -ne 0 ];078    then079        echo "Unable to mount $RMANBACKUP_MOUNTPOINT... exiting"080        exit 1081    fi082else083    export RMANBACKUP_MOUNTPOIN=$ACTUAL_MOUNTPOINT084fi085export PATH=$ORACLE_HOME/bin:$PATH086echo "Creating Dir $RMANBACKUP_MOUNTPOINT/$SID'/full'"087if [ ! -e $RMANBACKUP_MOUNTPOINT/$SID'/full' ]088then089    mkdir -p $RMANBACKUP_MOUNTPOINT/$SID'/full'090    if [ $? -eq 0 ];091    then092        echo "Created directory for full backup $RMANBACKUP_MOUNTPOINT/$SID/full"093    else094        echo "Oracle user does not have permission for $RMANBACKUP_MOUNTPOINT directory... exiting"095        exit 1096    fi097elif [ ! -d $RMANBACKUP_MOUNTPOINT/${SID}'/full' ];098then099    echo "$RMANBACKUP_MOUNTPOINT is not a directory... exiting"100    exit 1101fi102#Creating Archivelog Directory103if [ ! -e $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs' ]104then105    mkdir -p $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs'106    if [ $? -eq 0 ];107    then108        echo "Created directory for archivelogs backup $RMANBACKUP_MOUNTPOINT/$SID/archivelogs"109    else110        echo "Oracle user does not have permission for $RMANBACKUP_MOUNTPOINT directory... exiting"111        exit 1112    fi113elif [ ! -d $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs' ];114then115    echo "$RMANBACKUP_MOUNTPOINT is not a directory... exiting"116    exit 1117fi118export LOG_FILE_DIR=$RMANBACKUP_MOUNTPOINT/'_workspace/RMAN_Logs'119echo "Creating Log File Dir: =$RMANBACKUP_MOUNTPOINT'/_workspace/RMAN_Logs'"120if [ ! -e $LOG_FILE_DIR ]121then122    mkdir -p $LOG_FILE_DIR123    if [ $? -eq 0 ];124    then125        echo "Created log directory for oracle backup $LOG_FILE_DIR"126    else127        echo "Oracle user does not have permission for $LOG_FILE_DIR directory... exiting"128        exit 1129    fi130fi131RMANBACKUP_MOUNTPOINT_FULL=$RMANBACKUP_MOUNTPOINT/$SID132echo -n >$LOG_FILE_DIR'/rman_archivelog_backup.log'133touch $RMANBACKUP_MOUNTPOINT/_workspace/134if [ $? -ne 0 ];135then136    echo "$RMANBACKUP_MOUNTPOINT directory is not writable.. exiting"137    exit 1138fi139#Checking if any .lock file is present and deleting the same if the PID is NOT running.140export is_lock_file_present=`find ${RMANBACKUP_MOUNTPOINT} -type f -name ".RMAN_FULL_lock_*"|wc -l `141if [[ ${is_lock_file_present} -ne 0 ]]142then143        for _lock_file in `find ${RMANBACKUP_MOUNTPOINT} -type f -name ".RMAN_FULL_lock_*" | xargs `144        do145                export _pid=`echo ${_lock_file}|cut -d"_" -f4`146                export is_pid_proc_running=`ps -ef|grep ${_pid}|grep -v grep | wc -l`147                if [[ ${is_pid_proc_running} -ne 0 ]]148                then149                        echo "[INFO] Full backup Lock File: ${_lock_file} is present and PID is active"150                        echo "[ERROR] One Full backup is already in progress with process ${_pid}. Exiting current backup"151                        exit 1152                else153                        echo "[INFO] Full backup Lock File: ${_lock_file} is present and PID is NOT active"154                        echo "Deleting ${_lock_file}"155                        rm ${_lock_file}156                        if [ -e ${_lock_file} ]157                        then158                                echo "ERROR deleting file ${_lock_file}"159                        fi160                fi161        done162fi163# Creating a .lock file to represnt current active full/diff backup.164export file_stamp=`date | sed -e 's/ /_/g'`165export PID=`echo $$`166export LOCK_FILE=`echo ${RMANBACKUP_MOUNTPOINT}/.RMAN_FULL_lock_${PID}_${file_stamp}`167echo -n > ${LOCK_FILE}168if [ -e ${LOCK_FILE} ]169then170        echo "[INFO] Lock file created: ${LOCK_FILE}"171else172        echo "Error creating lock file: ${LOCK_FILE}"173        echo "[ERROR] Backup will now stop"174        exit 3175fi176#Calling Start RMAN Backup177export res_rmanbackup=$(curl -X POST http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/${SID}/full/rmanbackup 2> /dev/null)178if [ $? -ne 0 ];179then180    echo "Request to start phoenix backup failed... exiting"181    echo "Response from Phoenix Backup Store: "$res_rmanbackup182    exit 1183fi184echo "Response RMAN Backup: ${res_rmanbackup}"185export SNAPSHOT_NAME=`echo $res_rmanbackup|awk -F "snap_name" '{print $2}'|cut -d '"' -f3`186if [ -z "$SNAPSHOT_NAME" ];187then188    echo "Failed to get Snapshot name. Exiting. Please check Export Service Logs in PBS"189    exit 1190fi191echo "Snapshot to be created ${SNAPSHOT_NAME}"192echo -n >$LOG_FILE_DIR'/rman_archivelog_backup_'${SNAPSHOT_NAME}_${ORACLE_SID}'.log'193export RMAN_LOGFILE=$LOG_FILE_DIR'/rman_archivelog_backup_'${SNAPSHOT_NAME}_${ORACLE_SID}'.log'194echo "RMAN Logfile: ${RMAN_LOGFILE}"195echo "Starting with RMAN backup. RMAN Log File: $RMAN_LOGFILE"196PARALLELISM=1197rman log=$RMAN_LOGFILE 2> /dev/null << EOF198connect target /199set echo on;200configure backup optimization on;201configure controlfile autobackup on;202configure device type disk parallelism ${PARALLELISM} BACKUP TYPE TO COPY;203configure datafile backup copies for device type disk to 1;204configure archivelog backup copies for device type disk to 1;205configure controlfile autobackup format for device type disk to '${RMANBACKUP_MOUNTPOINT_FULL}/archivelogs/arch_controlfile_%%d_%%F.bkp';206run207{208sql 'alter system archive log current';209backup as backupset format '${RMANBACKUP_MOUNTPOINT_FULL}/archivelogs/%%d_%%h_%%e_%%s_%%t.arc' archivelog all not backed up;210#Force is to ignore I/O errors211delete noprompt obsolete device type disk;212delete force NOPROMPT expired copy;213delete force NOPROMPT expired backup;214crosscheck backup;215crosscheck copy;216}217configure backup optimization clear;218configure controlfile autobackup clear;219exit220EOF221export RMAN_EXIT_STATUS=$?222if [ $RMAN_EXIT_STATUS -ne 0 ];223then224    echo ""225    echo "rman failed with status $RMAN_EXIT_STATUS.. exiting"226    rm ${LOCK_FILE}227    if [ -e ${LOCK_FILE} ]228    then229        echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}"230    else231        dt=`date | sed -e 's/ /_/g'`232        echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} "233    fi234    exit 1235fi236echo "Triggering Post-Script operations"237echo "Notifying Phoenix to upload RMAN Logs"238echo "RMAN log location: $LOG_FILE_DIR/rman_archivelog_backup_${SNAPSHOT_NAME}_${ORACLE_SID}.log"239echo "Notifying Phoenix to upload RMAN Logs"240rman_uploadlog_res=$(curl -X POST -H "Content-Type: multipart/form-data" -F "file=@$LOG_FILE_DIR/rman_archivelog_backup_${SNAPSHOT_NAME}_${ORACLE_SID}.log" -F mountpoint=$RMANBACKUP_MOUNTPOINT -F platform=linux http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/uploadlog 2> /dev/null)241if [ $? -ne 0 ];242then243    echo "Request to send RMAN Logs failed..."244    echo "Response from Phoenix Backup Store: "$rman_uploadlog_res245fi246rm ${LOCK_FILE}247if [ -e ${LOCK_FILE} ]248then249        echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}"250else251        dt=`date | sed -e 's/ /_/g'`252        echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} "253fi254echo "Notifying Phoenix to end backup"255export final_res=$(curl -X PUT http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/backup 2> /dev/null)256if [ $? -ne 0 ];257then258    echo "Request to end phoenix backup failed... exiting"259    echo "Response from Phoenix Backup Store: "$final_res260    rm ${LOCK_FILE}261    if [ -e ${LOCK_FILE} ]262    then263        echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}"264    else265        dt=`date | sed -e 's/ /_/g'`266        echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} "267    fi268    exit 5269fi270export ERROR_CODE=$(echo $final_res|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1)271if [ $ERROR_CODE -ne 0 ];272then273    echo "Response from Phoenix Backup Store: "$res274    echo "Request to start Phoenix backup failed... exiting"275    exit 7276fi277echo $final_res278echo "Exiting with successful status"
Did this answer your question?