#!/usr/bin/ksh # # RMAN DB backup with incremental Merge # Written for HCL / Nokia # v1.0 - James Pattinson - October 2025 # # usage: rman_db.ksh get_script_dir() { # Portable way to get script directory for Linux and HP/UX (ksh compatible) src="$0" while [ -h "$src" ]; do dir=$(cd -P $(dirname "$src") >/dev/null 2>&1 && pwd) src=$(readlink "$src") case $src in /*) ;; # absolute path *) src="$dir/$src";; esac 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 . $MYDIR/rbk_api.conf . $MYDIR/oracle_funcs.ksh #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/data 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 echo "DEBUG: numChannels=$numChannels, MOUNTPOINT=$MOUNTPOINT" 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 allocate="" release="" i=0 while [ $i -lt $numChannels ]; do allocate="$allocate allocate channel 'c$i' device type disk format '$MOUNTPOINT/c$i/%U';" release="$release release channel c$i;" i=$(expr $i + 1) 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