From 09fd3b2c6788d1b48df1fcc5986e70a2e97f500e Mon Sep 17 00:00:00 2001 From: James Pattinson Date: Tue, 28 Oct 2025 12:21:11 -0400 Subject: [PATCH] more little fixes --- README.md | 5 +++++ oracle_funcs.ksh | 1 - rman_db.ksh | 19 +++++++++++++++---- rman_logs.ksh | 34 +++++++++++++++++++++++++--------- rubrik.conf.example | 31 +++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 14 deletions(-) create mode 100755 rubrik.conf.example diff --git a/README.md b/README.md index 916059b..17802c4 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,9 @@ MOUNTPOINT_PREFIX="/rubrik_" HOSTLOGRET=2 MV_SPACE_WARN=75 +# Number of RMAN channels to allocate per NFS mount +RMAN_CHANNELS_PER_MOUNT=1 + # Logging directories API_LOG_DIR=/tmp/rubrik RMAN_LOG_DIR=/tmp/rubrik/rman @@ -95,6 +98,7 @@ Performs RMAN database backup with incremental merge to Rubrik Managed Volume. **Features:** - Incremental level 1 backup with merge - Automatic MV open/close +- Configurable RMAN channels per NFS mount (RMAN_CHANNELS_PER_MOUNT) - Disk space monitoring - Email alerts on failure/success - Archive log backup @@ -109,6 +113,7 @@ Performs RMAN archive log backup to Rubrik Managed Volume. **Features:** - Backs up all not-backed-up archive logs +- Configurable RMAN channels per NFS mount (RMAN_CHANNELS_PER_MOUNT) - Automatic MV open/close - Disk space monitoring - Optional host-side log purging diff --git a/oracle_funcs.ksh b/oracle_funcs.ksh index 4770a4a..5d860f6 100755 --- a/oracle_funcs.ksh +++ b/oracle_funcs.ksh @@ -37,7 +37,6 @@ case "$os_name" in DATE=$(command -v gdate) else DATE=$(command -v date) - echo "WARNING: GNU date (gdate) not found. Date arithmetic may not work on HP/UX." >&2 fi ;; *) diff --git a/rman_db.ksh b/rman_db.ksh index 8d4fcf1..1ba1ddc 100755 --- a/rman_db.ksh +++ b/rman_db.ksh @@ -68,7 +68,12 @@ fi echo Running RMAN with log to $RMAN_LOG -if [ $numChannels -eq 1 ]; then +# Default RMAN channels per mount if not set +RMAN_CHANNELS_PER_MOUNT=${RMAN_CHANNELS_PER_MOUNT:-1} + +total_channels=$(expr $numChannels \* $RMAN_CHANNELS_PER_MOUNT) + +if [ $total_channels -eq 1 ]; then allocate="allocate channel 'ch1' device type disk format '$MOUNTPOINT/%U';" release="release channel ch1;" channel0="$MOUNTPOINT" @@ -77,15 +82,21 @@ else 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;" + j=0 + while [ $j -lt $RMAN_CHANNELS_PER_MOUNT ]; do + suffix=$(echo $j | tr '0123456789' 'abcdefghijklmnopqrstuvwxyz') + allocate="$allocate allocate channel 'c${i}${suffix}' device type disk format '$MOUNTPOINT/c$i/%U';" + release="$release release channel c${i}${suffix};" + j=$(expr $j + 1) + done 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') +startTime=$(perl -e 'use POSIX qw(strftime); $time = time() - 3600; print strftime("%m-%d-%Y %H:%M:%S", localtime($time))') # RMAN Part Here ############################################################################### diff --git a/rman_logs.ksh b/rman_logs.ksh index 8e12488..f4facea 100755 --- a/rman_logs.ksh +++ b/rman_logs.ksh @@ -62,15 +62,31 @@ fi echo Running RMAN with log to $RMAN_LOG -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" +# Default RMAN channels per mount if not set +RMAN_CHANNELS_PER_MOUNT=${RMAN_CHANNELS_PER_MOUNT:-1} + +total_channels=$(expr $numChannels \* $RMAN_CHANNELS_PER_MOUNT) + +if [ $total_channels -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 + j=0 + while [ $j -lt $RMAN_CHANNELS_PER_MOUNT ]; do + suffix=$(echo $j | tr '0123456789' 'abcdefghijklmnopqrstuvwxyz') + allocate="$allocate allocate channel 'c${i}${suffix}' device type disk format '$MOUNTPOINT/c$i/%U';" + release="$release release channel c${i}${suffix};" + j=$(expr $j + 1) + done + i=$(expr $i + 1) + done + channel0="$MOUNTPOINT/c0" +fi # RMAN Part Here diff --git a/rubrik.conf.example b/rubrik.conf.example new file mode 100755 index 0000000..0979128 --- /dev/null +++ b/rubrik.conf.example @@ -0,0 +1,31 @@ +# ID and Key for RSC Service Account (starts with client|) (use single quotes) +ID='client|xxxxxxxxxxxxxxxxxxx' +SECRET=xxxxxxxxxxxxxxxxxxxxxxxx + +# DNS name of Rubrik CDM +RUBRIK_IP= + +# Oracle Settings +MOUNTPOINT_PREFIX=/rubrik_ +# How many hours of archivelog to keep on host. 0 means do not purge logs +HOSTLOGRET=2 + +# Percentage threshold to warn if an MV filesystem is getting full +MV_SPACE_WARN=75 + +# Number of RMAN channels to allocate per MV channel +# NOTE: This is not a TOTAL. Total number of RMAN channels will be +# this multipled by the number of channels of the Managed Volume +RMAN_CHANNELS_PER_MOUNT=1 + +# Logging directories + +# API calls +API_LOG_DIR=/tmp/rubrik +# RMAN sessions +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