#!/bin/bash # # RMAN DB backup with incremental Merge # Written for HCL / Nokia # v1.0 - James Pattinson - October 2025 # # usage: rman_db.sh get_script_dir() { # Portable way to get script directory for Linux and HP/UX local src="$0" while [ -h "$src" ]; do dir="$(cd -P "$(dirname "$src")" >/dev/null 2>&1 && pwd)" src="$(readlink "$src")" [[ $src != /* ]] && src="$dir/$src" done cd -P "$(dirname "$src")" >/dev/null 2>&1 && pwd } MYDIR="$(get_script_dir)" export ORACLE_SID=$1 . $HOME/.profile export ORAENV_ASK=NO export ORACLE_SID=$1 . oraenv export ORAENV_ASK=YES source $MYDIR/rbk_api.conf source $MYDIR/oracle_funcs.sh #ORACLE_SID=$1 usage() { echo "Usage: $0 ]" 1>&2; exit 1; } if [ -z "${ORACLE_SID}" ]; then usage fi #ORAENV_ASK=NO #. oraenv export NLS_DATE_FORMAT='mm-dd-yyyy hh24:mi:ss' export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 MOUNTPOINT=$MOUNTPOINT_PREFIX$ORACLE_SID mkdir -p $RMAN_LOG_DIR/$ORACLE_SID/ RMAN_LOG=$RMAN_LOG_DIR/$ORACLE_SID/rman_${ORACLE_SID}_DB_$(date +%d%m%y).log # Disk space check dusage=$(df -Ph | egrep "$MOUNTPOINT" | sed s/%//g | awk -v spaceWarn=$MV_SPACE_WARN '{ if($5 >= spaceWarn) print $0;}') if [ "$dusage" != "" ]; then echo "WARNING: Disk Space Alert - sending email" echo "$dusage" | mailx -s "WARNING: Rubrik MV Disk Space Alert On $(hostname) at $(date)" $ALERT_EMAILS else echo "INFO: Rubrik MV Disk usage is under threshold of ${MV_SPACE_WARN}%" fi get_data_mv open_mv if [ $? -ne 0 ]; then echo ERROR: Unable to open MV, aborting exit_with_error fi echo Running RMAN with log to $RMAN_LOG if [[ $numChannels -eq 1 ]]; then allocate="allocate channel 'ch1' device type disk format '$MOUNTPOINT/%U';" release="release channel ch1;" channel0="$MOUNTPOINT" else for i in $(seq 0 $(($numChannels - 1))); do allocate+="allocate channel 'c$i' device type disk format '$MOUNTPOINT/c$i/%U';" release+="release channel c$i;" done channel0="$MOUNTPOINT/c0" fi # Save the current time (minus one hour) to ensure we catch all archive logs startTime=$(date +%m-%d-%Y\ %H:%M:%S -d '-1 hour') # RMAN Part Here ############################################################################### #cat > /tmp/rman.cmd < /dev/null </dev/null close_mv