Minor tweaks

This commit is contained in:
2025-11-06 06:15:44 -05:00
parent 14b1d29384
commit c2ef3e05e3
5 changed files with 59 additions and 23 deletions

View File

@@ -2,7 +2,7 @@
#
# Oracle shell script support functions
# Written for HCL / Nokia
# v1.0 - James Pattinson - October 2025
# v1.0 - James Pattinson - November 2025
nowait=0
@@ -13,10 +13,17 @@ tabwidth=25
# Portable short hostname function
get_short_hostname() {
if hostname -s >/dev/null 2>&1; then
hostname -s
else
# Check OS type first - HP-UX hostname doesn't support -s
os_type=$(uname -s)
if [ "$os_type" = "HP-UX" ]; then
hostname | awk -F. '{print $1}'
else
# Try -s flag on other systems
if hostname -s >/dev/null 2>&1; then
hostname -s
else
hostname | awk -F. '{print $1}'
fi
fi
}
HOST=$(get_short_hostname)

View File

@@ -2,7 +2,7 @@
#
# RMAN DB backup with incremental Merge
# Written for HCL / Nokia
# v1.0 - James Pattinson - October 2025
# v1.0 - James Pattinson - November 2025
#
# usage: rman_db.ksh <ORACLE_SID>
@@ -16,6 +16,7 @@ MYDIR=$(get_script_dir)
export ORACLE_SID=$1
# . $HOME/.profile
. ~oracle/bin/setEnv.sh
export ORAENV_ASK=NO
export ORACLE_SID=$1
@@ -47,7 +48,7 @@ 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;}')
dusage=$(df -Pk | grep -E "$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
@@ -138,6 +139,6 @@ elif [ $EMAIL_SUCCESS -eq 1 ]; then
fi
# Change permission of backup files to enable alternate host restore
find $MOUNTPOINT -type f -exec chmod 644 {} + 2>/dev/null
find $MOUNTPOINT -type f -exec chmod 644 {} \; 2>/dev/null
close_mv
close_mv

View File

@@ -2,7 +2,7 @@
#
# RMAN Log backup
# Written for HCL / Nokia
# v1.1 - James Pattinson - October 2025
# v1.1 - James Pattinson - November 2025
#
# usage: rman_logs.ksh <ORACLE_SID>
@@ -15,6 +15,7 @@ MYDIR=$(get_script_dir)
export ORACLE_SID=$1
#. $HOME/.profile
. ~oracle/bin/setEnv.sh
export ORAENV_ASK=NO
export ORACLE_SID=$1
@@ -52,7 +53,7 @@ fi
MOUNTPOINT=$MOUNTPOINT_PREFIX/$ORACLE_SID/logs
# Disk space check
dusage=$(df -Ph | egrep "$MOUNTPOINT" | sed s/%//g | awk -v spaceWarn=$MV_SPACE_WARN '{ if($5 >= spaceWarn) print $0;}')
dusage=$(df -Pk | grep -E "$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
@@ -120,7 +121,7 @@ elif [ $EMAIL_SUCCESS -eq 1 ]; then
fi
# Change permission of backup files to enable alternate host restore
find $MOUNTPOINT -type f -exec chmod 644 {} + 2>/dev/null
find $MOUNTPOINT -type f -exec chmod 644 {} \; 2>/dev/null
close_mv
@@ -147,4 +148,4 @@ EOF
cat $RMAN_LOG | mailx -s "RMAN purge on ${HOST} for ${ORACLE_SID} " $ALERT_EMAILS
fi
fi
fi

View File

@@ -28,4 +28,4 @@ RMAN_LOG_DIR=/tmp/rubrik/rman
# List of email addresses to send failure alerts to
ALERT_EMAILS=root,oracle
# Set to 1 to enable email alert on success also
EMAIL_SUCCESS=1
EMAIL_SUCCESS=0

View File

@@ -16,17 +16,25 @@ get_script_dir() {
echo "$dir"
}
MYDIR=$(get_script_dir)
. $MYDIR/rbk_api.conf
. $MYDIR/rubrik.conf
. $MYDIR/oracle_funcs.ksh
usage() {
echo "Usage: $0 -d <DBNAME> -v <logs|data> -o <open|close>" 1>&2
echo "Usage: $0 -d <DBNAME> -v <logs|data> -o <open|close>"
echo " $0 -n <MV_NAME> -o <open|close>"
echo " -d Oracle DBNAME"
echo " -v Volume to operate on, logs or data"
echo " -o Operation to perform - open or close the MV"
echo " -n Specify MV name directly (use only with -o)"
exit 1
}
force=0
while getopts "d:v:o:" o; do
force=0
MVNAME=""
while getopts "d:v:o:n:" o; do
case "${o}" in
d)
DBNAME=${OPTARG}
@@ -37,6 +45,9 @@ while getopts "d:v:o:" o; do
o)
OPCODE=${OPTARG}
;;
n)
MVNAME=${OPTARG}
;;
*)
usage
;;
@@ -44,20 +55,36 @@ while getopts "d:v:o:" o; do
done
shift $((OPTIND-1))
if [ -z "${DBNAME}" ] || [ -z "${VOLUME}" ] || [ -z "${OPCODE}" ]; then
# Validate options
if [ -n "$MVNAME" ]; then
# Direct MV name mode: require -n and -o only
if [ -z "$OPCODE" ]; then
usage
fi
mv_name="$MVNAME"
elif [ -n "$DBNAME" ] && [ -n "$VOLUME" ] && [ -n "$OPCODE" ]; then
# Standard mode: require -d, -v, -o
mv_name=$(get_short_hostname)_${DBNAME}_${VOLUME}
else
usage
fi
# Script starts here
get_short_hostname() {
if hostname -s >/dev/null 2>&1; then
hostname -s
else
# Check OS type first - HP-UX hostname doesn't support -s
os_type=$(uname -s)
if [ "$os_type" = "HP-UX" ]; then
hostname | awk -F. '{print $1}'
else
# Try -s flag on other systems
if hostname -s >/dev/null 2>&1; then
hostname -s
else
hostname | awk -F. '{print $1}'
fi
fi
}
mv_name=$(get_short_hostname)_${DBNAME}_${VOLUME}
get_mv
case $OPCODE in