Template scripts for configuring OEM
Updated yesterday

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.

#Update ORACLE_SID for the database. Example: ORACLE_SID=PROD export ORACLE_SID=<> #Update ORACLE_BASE for your database host server. E.g. ORACLE_BASE=/u01/app/oracle export ORACLE_BASE=<> #Update ORACLE_HOME for the database. Example: ORACLE_HOME=/opt/oracle/product/18c/dbhome_1 export ORACLE_HOME=<> #Update PBS IP inside the quotes. Example: BACKUP_STORE_IP="172.xx.xx.xx" export BACKUP_STORE_IP="<>" #Update PBS Backup Mount name inside the quotes. Example: BACKUP_MOUNT="PRODMount" export BACKUP_MOUNT="<>" echo "Pre-Script execution is getting started" if [[ -z "${ORACLE_HOME}" ]]; then echo "Environment variable ORACLE_HOME not set... exiting" exit 1 fi if [[ -z "${ORACLE_SID}" ]]; then echo "Environment variable ORACLE_SID not set... exiting" exit 1 fi SID=${ORACLE_SID} echo "Validating backup request" validate_resp=$(curl -X GET http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/1.2/backup 2> /dev/null) if [ $? -ne 0 ]; then echo "Request to validate phoenix backup failed... exiting" echo "Response from Phoenix Backup Store: "$validate_resp exit 1 fi VALIDATE_ERROR_CODE=$(echo $validate_resp|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1) if [ $VALIDATE_ERROR_CODE -ne 0 ]; then echo "Response from Phoenix Backup Store: "$validate_resp echo "Request to validate Phoenix backup failed... exiting" exit 1 fi # Sample output format # {"error_code":0,"error_msg":"","result":{"is_reached_max_snapshots":false,"mount_name":"m2"}} export IS_REACHED_MAX_SNAPSHOTS=$(echo $validate_resp|awk -F "is_reached_max_snapshots" '{print $2}'|cut -d ',' -f1 |cut -d ':' -f2) if [ $IS_REACHED_MAX_SNAPSHOTS == "false" ]; then echo "Validation for phoenix backup succeeded" else echo "Response from Phoenix Backup Store: "$validate_resp echo "Validation for phoenix backup failed... exiting" exit 1 fi echo "Notifying Phoenix to start backup - Phoenix Backup Store=$BACKUP_STORE_IP mount name=$BACKUP_MOUNT" export res=$(curl -X POST http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/backup 2> /dev/null) if [ $? -ne 0 ]; then echo "Request to start phoenix backup failed... exiting" echo "Response from Phoenix Backup Store: "$res exit 1 fi # Sample output format # {"error_code":4295622665,"error_msg":"Backup mount does not exist on Export Service.","result":{"mount_name":"mount4","mount_path":""}} ERROR_CODE=$(echo $res|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1) if [ $ERROR_CODE -ne 0 ]; then echo "Response from Phoenix Backup Store: "$res echo "Request to start Phoenix backup failed... exiting" exit 1 fi export REMOTE_MOUNTPOINT=$BACKUP_STORE_IP:$(echo $res|awk -F "mount_path" '{print $2}'|cut -d '"' -f3) export RMANBACKUP_MOUNTPOINT=$(grep "^$REMOTE_MOUNTPOINT" /etc/fstab| sed 's/\s\+/ /g' |cut -d ' ' -f2) if [ -z "$RMANBACKUP_MOUNTPOINT" ]; then echo "Entry for Phoenix Backup Store mount not found in /etc/fstab... exiting" exit 1 fi export ACTUAL_MOUNTPOINT=$(mount|grep "^$REMOTE_MOUNTPOINT"|sed 's/\s\+/ /g' |cut -d " " -f3 2> /dev/null) if [ -z "$ACTUAL_MOUNTPOINT" ]; then mount $RMANBACKUP_MOUNTPOINT 2> /dev/null if [ $? -ne 0 ]; then echo "Unable to mount $RMANBACKUP_MOUNTPOINT... exiting" exit 1 fi else export RMANBACKUP_MOUNTPOIN=$ACTUAL_MOUNTPOINT fi export PATH=$ORACLE_HOME/bin:$PATH echo "Creating Dir $RMANBACKUP_MOUNTPOINT/$SID'/full'" if [ ! -e $RMANBACKUP_MOUNTPOINT/$SID'/full' ] then mkdir -p $RMANBACKUP_MOUNTPOINT/$SID'/full' if [ $? -eq 0 ]; then echo "Created directory for full backup $RMANBACKUP_MOUNTPOINT/$SID/full" else echo "Oracle user does not have permission for $RMANBACKUP_MOUNTPOINT directory... exiting" exit 1 fi elif [ ! -d $RMANBACKUP_MOUNTPOINT/${SID}'/full' ]; then echo "$RMANBACKUP_MOUNTPOINT is not a directory... exiting" exit 1 fi #Creating Archivelog Directory if [ ! -e $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs' ] then mkdir -p $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs' if [ $? -eq 0 ]; then echo "Created directory for archivelogs backup $RMANBACKUP_MOUNTPOINT/$SID/archivelogs" else echo "Oracle user does not have permission for $RMANBACKUP_MOUNTPOINT directory... exiting" exit 1 fi elif [ ! -d $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs' ]; then echo "$RMANBACKUP_MOUNTPOINT is not a directory... exiting" exit 1 fi export LOG_FILE_DIR=$RMANBACKUP_MOUNTPOINT/'_workspace/RMAN_Logs' echo "Creating Log File Dir: =$RMANBACKUP_MOUNTPOINT'/_workspace/RMAN_Logs'" if [ ! -e $LOG_FILE_DIR ] then mkdir -p $LOG_FILE_DIR if [ $? -eq 0 ]; then echo "Created log directory for oracle backup $LOG_FILE_DIR" else echo "Oracle user does not have permission for $LOG_FILE_DIR directory... exiting" exit 1 fi fi RMANBACKUP_MOUNTPOINT_FULL=$RMANBACKUP_MOUNTPOINT/$SID echo -n >$LOG_FILE_DIR'/rman_full_backup.log' touch $RMANBACKUP_MOUNTPOINT/_workspace/ if [ $? -ne 0 ]; then echo "$RMANBACKUP_MOUNTPOINT directory is not writable.. exiting" exit 1 fi #Checking if any .lock file is present and deleting the same if the PID is NOT running. export is_lock_file_present=`find ${RMANBACKUP_MOUNTPOINT} -type f -name ".RMAN_FULL_lock_*"|wc -l ` if [[ ${is_lock_file_present} -ne 0 ]] then for _lock_file in `find ${RMANBACKUP_MOUNTPOINT} -type f -name ".RMAN_FULL_lock_*" | xargs ` do export _pid=`echo ${_lock_file}|cut -d"_" -f4` export is_pid_proc_running=`ps -ef|grep ${_pid}|grep -v grep | wc -l` if [[ ${is_pid_proc_running} -ne 0 ]] then echo "[INFO] Full backup Lock File: ${_lock_file} is present and PID is active" echo "[ERROR] One Full backup is already in progress with process ${_pid}. Exiting current backup" exit 1 else echo "[INFO] Full backup Lock File: ${_lock_file} is present and PID is NOT active" echo "Deleting ${_lock_file}" rm ${_lock_file} if [ -e ${_lock_file} ] then echo "ERROR deleting file ${_lock_file}" fi fi done fi # Creating a .lock file to represnt current active full/diff backup. export file_stamp=`date | sed -e 's/ /_/g'` export PID=`echo $$` export LOCK_FILE=`echo ${RMANBACKUP_MOUNTPOINT}/.RMAN_FULL_lock_${PID}_${file_stamp}` echo -n > ${LOCK_FILE} if [ -e ${LOCK_FILE} ] then echo "[INFO] Lock file created: ${LOCK_FILE}" else echo "Error creating lock file: ${LOCK_FILE}" echo "[ERROR] Backup will now stop" exit 3 fi #Calling Start RMAN Backup export res_rmanbackup=$(curl -X POST http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/${SID}/full/rmanbackup 2> /dev/null) if [ $? -ne 0 ]; then echo "Request to start phoenix backup failed... exiting" echo "Response from Phoenix Backup Store: "$res_rmanbackup exit 1 fi echo "Response RMAN Backup: ${res_rmanbackup}" export SNAPSHOT_NAME=`echo $res_rmanbackup|awk -F "snap_name" '{print $2}'|cut -d '"' -f3` if [ -z "$SNAPSHOT_NAME" ]; then echo "Failed to get Snapshot name. Exiting. Please check Export Service Logs in PBS" exit 1 fi echo "Snapshot to be created ${SNAPSHOT_NAME}" echo -n >$LOG_FILE_DIR'/rman_full_backup_'${SNAPSHOT_NAME}_${ORACLE_SID}'.log' export RMAN_LOGFILE=$LOG_FILE_DIR'/rman_full_backup_'${SNAPSHOT_NAME}_${ORACLE_SID}'.log' echo "RMAN Logfile: ${RMAN_LOGFILE}" echo "Starting with RMAN backup. RMAN Log File: $RMAN_LOGFILE" PARALLELISM=1 rman log=$RMAN_LOGFILE 2> /dev/null << EOF connect target / set echo on; configure backup optimization on; configure controlfile autobackup on; configure device type disk parallelism $PARALLELISM BACKUP TYPE TO COPY; configure datafile backup copies for device type disk to 1; configure archivelog backup copies for device type disk to 1; configure channel device type disk format '${RMANBACKUP_MOUNTPOINT_FULL}/full/datafile_%%U.bkp'; configure controlfile autobackup format for device type disk to '${RMANBACKUP_MOUNTPOINT_FULL}/full/full_controlfile_%%d_%%F.bkp'; run { sql 'alter system archive log current'; backup incremental level 1 for recover of copy with tag 'phoenix_oracle_backup' database; recover copy of database with tag 'phoenix_oracle_backup'; sql 'alter system archive log current'; backup as backupset format '${RMANBACKUP_MOUNTPOINT_FULL}/archivelogs/%%d_%%h_%%e_%%s_%%t.arc' archivelog all not backed up; #Force is to ignore I/O errors delete noprompt obsolete device type disk; delete force NOPROMPT expired copy; delete force NOPROMPT expired backup; crosscheck backup; crosscheck copy; } configure backup optimization clear; configure controlfile autobackup clear; exit EOF export RMAN_EXIT_STATUS=$? if [ $RMAN_EXIT_STATUS -ne 0 ]; then echo "" echo "rman failed with status $RMAN_EXIT_STATUS.. exiting" rm ${LOCK_FILE} if [ -e ${LOCK_FILE} ] then echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}" else dt=`date | sed -e 's/ /_/g'` echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} " fi exit 1 fi echo "Triggering backup operation" echo "Notifying Phoenix to upload RMAN Logs" echo "RMAN log location: $LOG_FILE_DIR/rman_full_backup_${SNAPSHOT_NAME}_${ORACLE_SID}.log" echo "Notifying Phoenix to upload RMAN Logs" rman_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) if [ $? -ne 0 ]; then echo "Request to send RMAN Logs failed..." echo "Response from Phoenix Backup Store: "$rman_uploadlog_res fi rm ${LOCK_FILE} if [ -e ${LOCK_FILE} ] then echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}" else dt=`date | sed -e 's/ /_/g'` echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} " fi echo "Notifying Phoenix to end backup" export final_res=$(curl -X PUT http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/backup 2> /dev/null) if [ $? -ne 0 ]; then echo "Request to end phoenix backup failed... exiting" echo "Response from Phoenix Backup Store: "$final_res rm ${LOCK_FILE} if [ -e ${LOCK_FILE} ] then echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}" else dt=`date | sed -e 's/ /_/g'` echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} " fi exit 5 fi export ERROR_CODE=$(echo $final_res|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1) if [ $ERROR_CODE -ne 0 ]; then echo "Response from Phoenix Backup Store: "$res echo "Request to start Phoenix backup failed... exiting" exit 7 fi echo $final_res echo "Exiting with successful status"

oracle_oem_archivelog_backup.txt

#Update ORACLE_SID for the database. Example: ORACLE_SID=PROD export ORACLE_SID=<> #Update ORACLE_BASE for your database host server. E.g. ORACLE_BASE=/u01/app/oracle export ORACLE_BASE=<> #Update ORACLE_HOME for the database. Example: ORACLE_HOME=/opt/oracle/product/18c/dbhome_1 export ORACLE_HOME=<> #Update PBS IP inside the quotes. Example: BACKUP_STORE_IP="172.xx.xx.xx" export BACKUP_STORE_IP="<>" #Update PBS Backup Mount name inside the quotes. Example: BACKUP_MOUNT="PRODMount" export BACKUP_MOUNT="<>" echo "Pre-Script execution is getting started" if [[ -z "${ORACLE_HOME}" ]]; then echo "Environment variable ORACLE_HOME not set... exiting" exit 1 fi if [[ -z "${ORACLE_SID}" ]]; then echo "Environment variable ORACLE_SID not set... exiting" exit 1 fi SID=${ORACLE_SID} echo "Validating backup request" validate_resp=$(curl -X GET http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/1.2/backup 2> /dev/null) if [ $? -ne 0 ]; then echo "Request to validate phoenix backup failed... exiting" echo "Response from Phoenix Backup Store: "$validate_resp exit 1 fi VALIDATE_ERROR_CODE=$(echo $validate_resp|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1) if [ $VALIDATE_ERROR_CODE -ne 0 ]; then echo "Response from Phoenix Backup Store: "$validate_resp echo "Request to validate Phoenix backup failed... exiting" exit 1 fi # Sample output format # {"error_code":0,"error_msg":"","result":{"is_reached_max_snapshots":false,"mount_name":"m2"}} export IS_REACHED_MAX_SNAPSHOTS=$(echo $validate_resp|awk -F "is_reached_max_snapshots" '{print $2}'|cut -d ',' -f1 |cut -d ':' -f2) if [ $IS_REACHED_MAX_SNAPSHOTS == "false" ]; then echo "Validation for phoenix backup succeeded" else echo "Response from Phoenix Backup Store: "$validate_resp echo "Validation for phoenix backup failed... exiting" exit 1 fi echo "Notifying Phoenix to start backup - Phoenix Backup Store=$BACKUP_STORE_IP mount name=$BACKUP_MOUNT" export res=$(curl -X POST http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/backup 2> /dev/null) if [ $? -ne 0 ]; then echo "Request to start phoenix backup failed... exiting" echo "Response from Phoenix Backup Store: "$res exit 1 fi # Sample output format # {"error_code":4295622665,"error_msg":"Backup mount does not exist on Export Service.","result":{"mount_name":"mount4","mount_path":""}} ERROR_CODE=$(echo $res|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1) if [ $ERROR_CODE -ne 0 ]; then echo "Response from Phoenix Backup Store: "$res echo "Request to start Phoenix backup failed... exiting" exit 1 fi export REMOTE_MOUNTPOINT=$BACKUP_STORE_IP:$(echo $res|awk -F "mount_path" '{print $2}'|cut -d '"' -f3) export RMANBACKUP_MOUNTPOINT=$(grep "^$REMOTE_MOUNTPOINT" /etc/fstab| sed 's/\s\+/ /g' |cut -d ' ' -f2) if [ -z "$RMANBACKUP_MOUNTPOINT" ]; then echo "Entry for Phoenix Backup Store mount not found in /etc/fstab... exiting" exit 1 fi export ACTUAL_MOUNTPOINT=$(mount|grep "^$REMOTE_MOUNTPOINT"|sed 's/\s\+/ /g' |cut -d " " -f3 2> /dev/null) if [ -z "$ACTUAL_MOUNTPOINT" ]; then mount $RMANBACKUP_MOUNTPOINT 2> /dev/null if [ $? -ne 0 ]; then echo "Unable to mount $RMANBACKUP_MOUNTPOINT... exiting" exit 1 fi else export RMANBACKUP_MOUNTPOIN=$ACTUAL_MOUNTPOINT fi export PATH=$ORACLE_HOME/bin:$PATH echo "Creating Dir $RMANBACKUP_MOUNTPOINT/$SID'/full'" if [ ! -e $RMANBACKUP_MOUNTPOINT/$SID'/full' ] then mkdir -p $RMANBACKUP_MOUNTPOINT/$SID'/full' if [ $? -eq 0 ]; then echo "Created directory for full backup $RMANBACKUP_MOUNTPOINT/$SID/full" else echo "Oracle user does not have permission for $RMANBACKUP_MOUNTPOINT directory... exiting" exit 1 fi elif [ ! -d $RMANBACKUP_MOUNTPOINT/${SID}'/full' ]; then echo "$RMANBACKUP_MOUNTPOINT is not a directory... exiting" exit 1 fi #Creating Archivelog Directory if [ ! -e $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs' ] then mkdir -p $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs' if [ $? -eq 0 ]; then echo "Created directory for archivelogs backup $RMANBACKUP_MOUNTPOINT/$SID/archivelogs" else echo "Oracle user does not have permission for $RMANBACKUP_MOUNTPOINT directory... exiting" exit 1 fi elif [ ! -d $RMANBACKUP_MOUNTPOINT/${SID}'/archivelogs' ]; then echo "$RMANBACKUP_MOUNTPOINT is not a directory... exiting" exit 1 fi export LOG_FILE_DIR=$RMANBACKUP_MOUNTPOINT/'_workspace/RMAN_Logs' echo "Creating Log File Dir: =$RMANBACKUP_MOUNTPOINT'/_workspace/RMAN_Logs'" if [ ! -e $LOG_FILE_DIR ] then mkdir -p $LOG_FILE_DIR if [ $? -eq 0 ]; then echo "Created log directory for oracle backup $LOG_FILE_DIR" else echo "Oracle user does not have permission for $LOG_FILE_DIR directory... exiting" exit 1 fi fi RMANBACKUP_MOUNTPOINT_FULL=$RMANBACKUP_MOUNTPOINT/$SID echo -n >$LOG_FILE_DIR'/rman_archivelog_backup.log' touch $RMANBACKUP_MOUNTPOINT/_workspace/ if [ $? -ne 0 ]; then echo "$RMANBACKUP_MOUNTPOINT directory is not writable.. exiting" exit 1 fi #Checking if any .lock file is present and deleting the same if the PID is NOT running. export is_lock_file_present=`find ${RMANBACKUP_MOUNTPOINT} -type f -name ".RMAN_FULL_lock_*"|wc -l ` if [[ ${is_lock_file_present} -ne 0 ]] then for _lock_file in `find ${RMANBACKUP_MOUNTPOINT} -type f -name ".RMAN_FULL_lock_*" | xargs ` do export _pid=`echo ${_lock_file}|cut -d"_" -f4` export is_pid_proc_running=`ps -ef|grep ${_pid}|grep -v grep | wc -l` if [[ ${is_pid_proc_running} -ne 0 ]] then echo "[INFO] Full backup Lock File: ${_lock_file} is present and PID is active" echo "[ERROR] One Full backup is already in progress with process ${_pid}. Exiting current backup" exit 1 else echo "[INFO] Full backup Lock File: ${_lock_file} is present and PID is NOT active" echo "Deleting ${_lock_file}" rm ${_lock_file} if [ -e ${_lock_file} ] then echo "ERROR deleting file ${_lock_file}" fi fi done fi # Creating a .lock file to represnt current active full/diff backup. export file_stamp=`date | sed -e 's/ /_/g'` export PID=`echo $$` export LOCK_FILE=`echo ${RMANBACKUP_MOUNTPOINT}/.RMAN_FULL_lock_${PID}_${file_stamp}` echo -n > ${LOCK_FILE} if [ -e ${LOCK_FILE} ] then echo "[INFO] Lock file created: ${LOCK_FILE}" else echo "Error creating lock file: ${LOCK_FILE}" echo "[ERROR] Backup will now stop" exit 3 fi #Calling Start RMAN Backup export res_rmanbackup=$(curl -X POST http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/${SID}/full/rmanbackup 2> /dev/null) if [ $? -ne 0 ]; then echo "Request to start phoenix backup failed... exiting" echo "Response from Phoenix Backup Store: "$res_rmanbackup exit 1 fi echo "Response RMAN Backup: ${res_rmanbackup}" export SNAPSHOT_NAME=`echo $res_rmanbackup|awk -F "snap_name" '{print $2}'|cut -d '"' -f3` if [ -z "$SNAPSHOT_NAME" ]; then echo "Failed to get Snapshot name. Exiting. Please check Export Service Logs in PBS" exit 1 fi echo "Snapshot to be created ${SNAPSHOT_NAME}" echo -n >$LOG_FILE_DIR'/rman_archivelog_backup_'${SNAPSHOT_NAME}_${ORACLE_SID}'.log' export RMAN_LOGFILE=$LOG_FILE_DIR'/rman_archivelog_backup_'${SNAPSHOT_NAME}_${ORACLE_SID}'.log' echo "RMAN Logfile: ${RMAN_LOGFILE}" echo "Starting with RMAN backup. RMAN Log File: $RMAN_LOGFILE" PARALLELISM=1 rman log=$RMAN_LOGFILE 2> /dev/null << EOF connect target / set echo on; configure backup optimization on; configure controlfile autobackup on; configure device type disk parallelism ${PARALLELISM} BACKUP TYPE TO COPY; configure datafile backup copies for device type disk to 1; configure archivelog backup copies for device type disk to 1; configure controlfile autobackup format for device type disk to '${RMANBACKUP_MOUNTPOINT_FULL}/archivelogs/arch_controlfile_%%d_%%F.bkp'; run { sql 'alter system archive log current'; backup as backupset format '${RMANBACKUP_MOUNTPOINT_FULL}/archivelogs/%%d_%%h_%%e_%%s_%%t.arc' archivelog all not backed up; #Force is to ignore I/O errors delete noprompt obsolete device type disk; delete force NOPROMPT expired copy; delete force NOPROMPT expired backup; crosscheck backup; crosscheck copy; } configure backup optimization clear; configure controlfile autobackup clear; exit EOF export RMAN_EXIT_STATUS=$? if [ $RMAN_EXIT_STATUS -ne 0 ]; then echo "" echo "rman failed with status $RMAN_EXIT_STATUS.. exiting" rm ${LOCK_FILE} if [ -e ${LOCK_FILE} ] then echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}" else dt=`date | sed -e 's/ /_/g'` echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} " fi exit 1 fi echo "Triggering Post-Script operations" echo "Notifying Phoenix to upload RMAN Logs" echo "RMAN log location: $LOG_FILE_DIR/rman_archivelog_backup_${SNAPSHOT_NAME}_${ORACLE_SID}.log" echo "Notifying Phoenix to upload RMAN Logs" rman_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) if [ $? -ne 0 ]; then echo "Request to send RMAN Logs failed..." echo "Response from Phoenix Backup Store: "$rman_uploadlog_res fi rm ${LOCK_FILE} if [ -e ${LOCK_FILE} ] then echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}" else dt=`date | sed -e 's/ /_/g'` echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} " fi echo "Notifying Phoenix to end backup" export final_res=$(curl -X PUT http://$BACKUP_STORE_IP:9090/druva-phoenix/v1/mounts/$BACKUP_MOUNT/backup 2> /dev/null) if [ $? -ne 0 ]; then echo "Request to end phoenix backup failed... exiting" echo "Response from Phoenix Backup Store: "$final_res rm ${LOCK_FILE} if [ -e ${LOCK_FILE} ] then echo "[ERROR] Could NOT delete Lock file: ${LOCK_FILE}" else dt=`date | sed -e 's/ /_/g'` echo "[INFO] Lock file deleted: ${LOCK_FILE} at ${dt} " fi exit 5 fi export ERROR_CODE=$(echo $final_res|awk -F "error_code" '{print $2}' | cut -d ':' -f2|cut -d ',' -f1) if [ $ERROR_CODE -ne 0 ]; then echo "Response from Phoenix Backup Store: "$res echo "Request to start Phoenix backup failed... exiting" exit 7 fi echo $final_res echo "Exiting with successful status"

Did this answer your question?