Compare commits
3 Commits
14b1d29384
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 04d946aa00 | |||
| bd7d5da70e | |||
| c2ef3e05e3 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -23,3 +23,5 @@ rubrik.conf
|
|||||||
# Other common ignores
|
# Other common ignores
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
|
|
||||||
|
releases/
|
||||||
|
|||||||
22
list_mv.ksh
22
list_mv.ksh
@@ -5,13 +5,26 @@
|
|||||||
# v1.1 - James Pattinson - October 2025
|
# v1.1 - James Pattinson - October 2025
|
||||||
#
|
#
|
||||||
# usage: list_mv.ksh
|
# usage: list_mv.ksh
|
||||||
|
_SCRIPT_="$0"
|
||||||
|
|
||||||
get_script_dir() {
|
get_script_dir() {
|
||||||
src="$0"
|
script="$1"
|
||||||
dir=$(cd -P "$(dirname "$src")" >/dev/null 2>&1 && pwd)
|
case "$script" in
|
||||||
echo "$dir"
|
/*) abs_path="$script" ;;
|
||||||
|
*) abs_path="$PWD/$script" ;;
|
||||||
|
esac
|
||||||
|
while [ -L "$abs_path" ]; do
|
||||||
|
link=$(readlink "$abs_path")
|
||||||
|
case "$link" in
|
||||||
|
/*) abs_path="$link" ;;
|
||||||
|
*) abs_path="$(dirname "$abs_path")/$link" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
script_dir=$(dirname "$abs_path")
|
||||||
|
cd "$script_dir" 2>/dev/null && pwd
|
||||||
}
|
}
|
||||||
MYDIR=$(get_script_dir)
|
|
||||||
|
MYDIR=$(get_script_dir "$_SCRIPT_")
|
||||||
. $MYDIR/rubrik.conf
|
. $MYDIR/rubrik.conf
|
||||||
. $MYDIR/oracle_funcs.ksh
|
. $MYDIR/oracle_funcs.ksh
|
||||||
|
|
||||||
@@ -45,3 +58,4 @@ awk '
|
|||||||
' /tmp/rbkresponse.$$
|
' /tmp/rbkresponse.$$
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Oracle shell script support functions
|
# Oracle shell script support functions
|
||||||
# Written for HCL / Nokia
|
# Written for HCL / Nokia
|
||||||
# v1.0 - James Pattinson - October 2025
|
# v1.0 - James Pattinson - November 2025
|
||||||
|
|
||||||
nowait=0
|
nowait=0
|
||||||
|
|
||||||
@@ -13,10 +13,17 @@ tabwidth=25
|
|||||||
|
|
||||||
# Portable short hostname function
|
# Portable short hostname function
|
||||||
get_short_hostname() {
|
get_short_hostname() {
|
||||||
if hostname -s >/dev/null 2>&1; then
|
# Check OS type first - HP-UX hostname doesn't support -s
|
||||||
hostname -s
|
os_type=$(uname -s)
|
||||||
else
|
if [ "$os_type" = "HP-UX" ]; then
|
||||||
hostname | awk -F. '{print $1}'
|
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
|
fi
|
||||||
}
|
}
|
||||||
HOST=$(get_short_hostname)
|
HOST=$(get_short_hostname)
|
||||||
@@ -73,10 +80,11 @@ exit_with_error() {
|
|||||||
|
|
||||||
check_http_error() {
|
check_http_error() {
|
||||||
# All good responses start with a 2
|
# All good responses start with a 2
|
||||||
if [ ${http_response:0:1} != "2" ]; then
|
first_char=$(echo "$http_response" | cut -c1)
|
||||||
echo FATAL: HTTP error from API call: $http_response. The server responded with:
|
if [ "$first_char" != "2" ]; then
|
||||||
cat /tmp/rbkresponse.$$ ; echo ; exit_with_error
|
echo FATAL: HTTP error from API call: $http_response. The server responded with:
|
||||||
fi
|
cat /tmp/rbkresponse.$$ ; echo ; exit_with_error
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_pid() {
|
check_pid() {
|
||||||
@@ -210,7 +218,7 @@ get_mv() {
|
|||||||
mvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/rbkresponse.$$)
|
mvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/rbkresponse.$$)
|
||||||
numChannels=$(awk '{match($0, /"numChannels":[ ]*[0-9]+/); if (RSTART > 0) {val=substr($0, RSTART, RLENGTH); sub(/.*:[ ]*/, "", val); print val}}' /tmp/rbkresponse.$$)
|
numChannels=$(awk '{match($0, /"numChannels":[ ]*[0-9]+/); if (RSTART > 0) {val=substr($0, RSTART, RLENGTH); sub(/.*:[ ]*/, "", val); print val}}' /tmp/rbkresponse.$$)
|
||||||
|
|
||||||
if [[ $mvId == "" ]]; then
|
if [ -z "$mvId" ]; then
|
||||||
echo ERROR: MV with name $mv_name was not found
|
echo ERROR: MV with name $mv_name was not found
|
||||||
exit_with_error
|
exit_with_error
|
||||||
fi
|
fi
|
||||||
@@ -219,7 +227,7 @@ get_mv() {
|
|||||||
|
|
||||||
get_data_mv() {
|
get_data_mv() {
|
||||||
|
|
||||||
mv_name=${HOST}_${ORACLE_SID}_data
|
mv_name=${HOST}_${ORACLE_SID}_Data
|
||||||
|
|
||||||
ENDPOINT="https://$RUBRIK_IP/api/internal/managed_volume?name=$mv_name&is_relic=false"
|
ENDPOINT="https://$RUBRIK_IP/api/internal/managed_volume?name=$mv_name&is_relic=false"
|
||||||
rest_api_get
|
rest_api_get
|
||||||
@@ -227,7 +235,7 @@ get_data_mv() {
|
|||||||
mvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/rbkresponse.$$)
|
mvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/rbkresponse.$$)
|
||||||
numChannels=$(awk '{match($0, /"numChannels":[ ]*[0-9]+/); if (RSTART > 0) {val=substr($0, RSTART, RLENGTH); sub(/.*:[ ]*/, "", val); print val}}' /tmp/rbkresponse.$$)
|
numChannels=$(awk '{match($0, /"numChannels":[ ]*[0-9]+/); if (RSTART > 0) {val=substr($0, RSTART, RLENGTH); sub(/.*:[ ]*/, "", val); print val}}' /tmp/rbkresponse.$$)
|
||||||
|
|
||||||
if [[ $mvId == "" ]]; then
|
if [ -z "$mvId" ]; then
|
||||||
echo ERROR: MV with name $mv_name was not found
|
echo ERROR: MV with name $mv_name was not found
|
||||||
exit_with_error
|
exit_with_error
|
||||||
fi
|
fi
|
||||||
@@ -238,16 +246,16 @@ get_log_mv() {
|
|||||||
|
|
||||||
# Look for a log volume. If not present, return the data volume
|
# Look for a log volume. If not present, return the data volume
|
||||||
|
|
||||||
mv_name=${HOST}_${ORACLE_SID}_logs
|
mv_name=${HOST}_${ORACLE_SID}_Log
|
||||||
ENDPOINT="https://$RUBRIK_IP/api/internal/managed_volume?name=$mv_name&is_relic=false"
|
ENDPOINT="https://$RUBRIK_IP/api/internal/managed_volume?name=$mv_name&is_relic=false"
|
||||||
rest_api_get
|
rest_api_get
|
||||||
|
|
||||||
logMvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/rbkresponse.$$)
|
logMvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/rbkresponse.$$)
|
||||||
|
|
||||||
if [[ $logMvId == "" ]]; then
|
if [ -z "$logMvId" ]; then
|
||||||
echo "INFO: Log volume ($mv_name) not found. Logs will be written to DB volume"
|
echo "INFO: Log volume ($mv_name) not found. Logs will be written to DB volume"
|
||||||
logMvPresent=0
|
logMvPresent=0
|
||||||
mv_name=${HOST}_${ORACLE_SID}_data
|
mv_name=${HOST}_${ORACLE_SID}_Data
|
||||||
|
|
||||||
ENDPOINT="https://$RUBRIK_IP/api/internal/managed_volume?name=$mv_name&is_relic=false"
|
ENDPOINT="https://$RUBRIK_IP/api/internal/managed_volume?name=$mv_name&is_relic=false"
|
||||||
rest_api_get
|
rest_api_get
|
||||||
@@ -255,19 +263,29 @@ get_log_mv() {
|
|||||||
mvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/rbkresponse.$$)
|
mvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/rbkresponse.$$)
|
||||||
numChannels=$(awk '{match($0, /"numChannels":[ ]*[0-9]+/); if (RSTART > 0) {val=substr($0, RSTART, RLENGTH); sub(/.*:[ ]*/, "", val); print val}}' /tmp/rbkresponse.$$)
|
numChannels=$(awk '{match($0, /"numChannels":[ ]*[0-9]+/); if (RSTART > 0) {val=substr($0, RSTART, RLENGTH); sub(/.*:[ ]*/, "", val); print val}}' /tmp/rbkresponse.$$)
|
||||||
|
|
||||||
if [[ $mvId == "" ]]; then
|
if [ -z "$mvId" ]; then
|
||||||
echo ERROR: MV with name $mv_name was not found
|
echo ERROR: MV with name $mv_name was not found
|
||||||
exit_with_error
|
exit_with_error
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
mvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/rbkresponse.$$)
|
mvId=$(awk '{match($0, /ManagedVolume:::[a-z0-9-]*/); if (RSTART > 0) {id=substr($0, RSTART, RLENGTH); sub(/"$/, "", id); print id}}' /tmp/rbkresponse.$$)
|
||||||
numChannels=$(awk '{match($0, /"numChannels":[ ]*[0-9]+/); if (RSTART > 0) {val=substr($0, RSTART, RLENGTH); sub(/.*:[ ]*/, "", val); print val}}' /tmp/rbkresponse.$$)
|
numChannels=$(awk '{match($0, /"numChannels":[ ]*[0-9]+/); if (RSTART > 0) {val=substr($0, RSTART, RLENGTH); sub(/.*:[ ]*/, "", val); print val}}' /tmp/rbkresponse.$$)
|
||||||
logMvPresent=1
|
logMvPresent=1
|
||||||
echo "INFO: Log volume ($mv_name) exists with $numChannels channels"
|
echo "INFO: Log volume ($mv_name) exists with $numChannels channels"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_oracle_env() {
|
||||||
|
ORACLE_HOME=$(awk -F: '$1 == "'$1'" {print $2}' /etc/oratab)
|
||||||
|
PATH=$PATH:$ORACLE_HOME/bin
|
||||||
|
ORACLE_SID=$1
|
||||||
|
if [ -z "$ORACLE_HOME" ]; then
|
||||||
|
echo "ERROR: SID $1 not found in /etc/oratab"
|
||||||
|
exit_with_error
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
open_mv() {
|
open_mv() {
|
||||||
|
|
||||||
PIDFILE=/tmp/mvLock_${mv_name}.pid
|
PIDFILE=/tmp/mvLock_${mv_name}.pid
|
||||||
|
|||||||
45
rman_db.ksh
45
rman_db.ksh
@@ -2,32 +2,38 @@
|
|||||||
#
|
#
|
||||||
# RMAN DB backup with incremental Merge
|
# RMAN DB backup with incremental Merge
|
||||||
# Written for HCL / Nokia
|
# Written for HCL / Nokia
|
||||||
# v1.0 - James Pattinson - October 2025
|
# v1.0 - James Pattinson - November 2025
|
||||||
#
|
#
|
||||||
# usage: rman_db.ksh <ORACLE_SID>
|
# usage: rman_db.ksh <ORACLE_SID>
|
||||||
|
|
||||||
|
_SCRIPT_="$0"
|
||||||
|
|
||||||
get_script_dir() {
|
get_script_dir() {
|
||||||
src="$0"
|
script="$1"
|
||||||
dir=$(cd -P "$(dirname "$src")" >/dev/null 2>&1 && pwd)
|
case "$script" in
|
||||||
echo "$dir"
|
/*) abs_path="$script" ;;
|
||||||
|
*) abs_path="$PWD/$script" ;;
|
||||||
|
esac
|
||||||
|
while [ -L "$abs_path" ]; do
|
||||||
|
link=$(readlink "$abs_path")
|
||||||
|
case "$link" in
|
||||||
|
/*) abs_path="$link" ;;
|
||||||
|
*) abs_path="$(dirname "$abs_path")/$link" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
script_dir=$(dirname "$abs_path")
|
||||||
|
cd "$script_dir" 2>/dev/null && pwd
|
||||||
}
|
}
|
||||||
MYDIR=$(get_script_dir)
|
|
||||||
|
|
||||||
export ORACLE_SID=$1
|
MYDIR=$(get_script_dir "$_SCRIPT_")
|
||||||
|
|
||||||
# . $HOME/.profile
|
|
||||||
|
|
||||||
export ORAENV_ASK=NO
|
|
||||||
export ORACLE_SID=$1
|
|
||||||
|
|
||||||
. oraenv
|
|
||||||
|
|
||||||
export ORAENV_ASK=YES
|
|
||||||
|
|
||||||
. $MYDIR/rubrik.conf
|
. $MYDIR/rubrik.conf
|
||||||
. $MYDIR/oracle_funcs.ksh
|
. $MYDIR/oracle_funcs.ksh
|
||||||
|
|
||||||
#ORACLE_SID=$1
|
set_oracle_env $1
|
||||||
|
|
||||||
|
export NLS_DATE_FORMAT='mm-dd-yyyy hh24:mi:ss'
|
||||||
|
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 <DBNAME>]" 1>&2
|
echo "Usage: $0 <DBNAME>]" 1>&2
|
||||||
@@ -38,16 +44,13 @@ if [ -z "${ORACLE_SID}" ]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export NLS_DATE_FORMAT='mm-dd-yyyy hh24:mi:ss'
|
|
||||||
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
|
|
||||||
|
|
||||||
MOUNTPOINT=$MOUNTPOINT_PREFIX/$ORACLE_SID/data
|
MOUNTPOINT=$MOUNTPOINT_PREFIX/$ORACLE_SID/data
|
||||||
|
|
||||||
mkdir -p $RMAN_LOG_DIR/$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
|
RMAN_LOG=$RMAN_LOG_DIR/$ORACLE_SID/rman_${ORACLE_SID}_DB_$(date +%d%m%y).log
|
||||||
|
|
||||||
# Disk space check
|
# 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
|
if [ "$dusage" != "" ]; then
|
||||||
echo "WARNING: Disk Space Alert - sending email"
|
echo "WARNING: Disk Space Alert - sending email"
|
||||||
echo "$dusage" | mailx -s "WARNING: Rubrik MV Disk Space Alert On $(hostname) at $(date)" $ALERT_EMAILS
|
echo "$dusage" | mailx -s "WARNING: Rubrik MV Disk Space Alert On $(hostname) at $(date)" $ALERT_EMAILS
|
||||||
@@ -138,6 +141,6 @@ elif [ $EMAIL_SUCCESS -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Change permission of backup files to enable alternate host restore
|
# 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
|
||||||
@@ -2,30 +2,39 @@
|
|||||||
#
|
#
|
||||||
# RMAN Log backup
|
# RMAN Log backup
|
||||||
# Written for HCL / Nokia
|
# Written for HCL / Nokia
|
||||||
# v1.1 - James Pattinson - October 2025
|
# v1.1 - James Pattinson - November 2025
|
||||||
#
|
#
|
||||||
# usage: rman_logs.ksh <ORACLE_SID>
|
# usage: rman_logs.ksh <ORACLE_SID>
|
||||||
|
|
||||||
|
_SCRIPT_="$0"
|
||||||
|
|
||||||
get_script_dir() {
|
get_script_dir() {
|
||||||
src="$0"
|
script="$1"
|
||||||
dir=$(cd -P "$(dirname "$src")" >/dev/null 2>&1 && pwd)
|
case "$script" in
|
||||||
echo "$dir"
|
/*) abs_path="$script" ;;
|
||||||
|
*) abs_path="$PWD/$script" ;;
|
||||||
|
esac
|
||||||
|
while [ -L "$abs_path" ]; do
|
||||||
|
link=$(readlink "$abs_path")
|
||||||
|
case "$link" in
|
||||||
|
/*) abs_path="$link" ;;
|
||||||
|
*) abs_path="$(dirname "$abs_path")/$link" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
script_dir=$(dirname "$abs_path")
|
||||||
|
cd "$script_dir" 2>/dev/null && pwd
|
||||||
}
|
}
|
||||||
MYDIR=$(get_script_dir)
|
|
||||||
export ORACLE_SID=$1
|
|
||||||
|
|
||||||
#. $HOME/.profile
|
MYDIR=$(get_script_dir "$_SCRIPT_")
|
||||||
|
|
||||||
export ORAENV_ASK=NO
|
|
||||||
export ORACLE_SID=$1
|
|
||||||
|
|
||||||
. oraenv
|
|
||||||
|
|
||||||
export ORAENV_ASK=YES
|
|
||||||
|
|
||||||
. $MYDIR/rubrik.conf
|
. $MYDIR/rubrik.conf
|
||||||
. $MYDIR/oracle_funcs.ksh
|
. $MYDIR/oracle_funcs.ksh
|
||||||
|
|
||||||
|
set_oracle_env $1
|
||||||
|
|
||||||
|
export NLS_DATE_FORMAT='mm-dd-yyyy hh24:mi:ss'
|
||||||
|
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 <DBNAME>]" 1>&2
|
echo "Usage: $0 <DBNAME>]" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -35,24 +44,26 @@ if [ -z "${ORACLE_SID}" ]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export NLS_DATE_FORMAT='mm-dd-yyyy hh24:mi:ss'
|
|
||||||
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
|
|
||||||
|
|
||||||
mkdir -p $RMAN_LOG_DIR/$ORACLE_SID/
|
mkdir -p $RMAN_LOG_DIR/$ORACLE_SID/
|
||||||
RMAN_LOG=$RMAN_LOG_DIR/$ORACLE_SID/rman_${ORACLE_SID}_LOG_$(date +%d%m%y).log
|
RMAN_LOG=$RMAN_LOG_DIR/$ORACLE_SID/rman_${ORACLE_SID}_LOG_$(date +%d%m%y).log
|
||||||
|
|
||||||
get_log_mv
|
get_log_mv
|
||||||
open_mv
|
open_mv
|
||||||
|
|
||||||
|
if [ -z "$numChannels" ]; then
|
||||||
|
echo "WARNING: numChannels not found, setting to 1"
|
||||||
|
numChannels=1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo ERROR: Unable to open MV, aborting
|
echo ERROR: Unable to open MV, aborting
|
||||||
exit_with_error
|
exit_with_error
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MOUNTPOINT=$MOUNTPOINT_PREFIX/$ORACLE_SID/logs
|
MOUNTPOINT=$MOUNTPOINT_PREFIX/$ORACLE_SID/log
|
||||||
|
|
||||||
# Disk space check
|
# 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
|
if [ "$dusage" != "" ]; then
|
||||||
echo "WARNING: Disk Space Alert - sending email"
|
echo "WARNING: Disk Space Alert - sending email"
|
||||||
echo "$dusage" | mailx -s "WARNING: Rubrik MV Disk Space Alert On $(hostname) at $(date)" $ALERT_EMAILS
|
echo "$dusage" | mailx -s "WARNING: Rubrik MV Disk Space Alert On $(hostname) at $(date)" $ALERT_EMAILS
|
||||||
@@ -120,7 +131,7 @@ elif [ $EMAIL_SUCCESS -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Change permission of backup files to enable alternate host restore
|
# 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
|
||||||
|
|
||||||
|
|||||||
@@ -28,4 +28,4 @@ RMAN_LOG_DIR=/tmp/rubrik/rman
|
|||||||
# List of email addresses to send failure alerts to
|
# List of email addresses to send failure alerts to
|
||||||
ALERT_EMAILS=root,oracle
|
ALERT_EMAILS=root,oracle
|
||||||
# Set to 1 to enable email alert on success also
|
# Set to 1 to enable email alert on success also
|
||||||
EMAIL_SUCCESS=1
|
EMAIL_SUCCESS=0
|
||||||
|
|||||||
@@ -10,23 +10,45 @@
|
|||||||
# -v Volume to operate on, logs or data
|
# -v Volume to operate on, logs or data
|
||||||
# -o Operation to perform - open or close the MV
|
# -o Operation to perform - open or close the MV
|
||||||
|
|
||||||
|
_SCRIPT_="$0"
|
||||||
|
|
||||||
get_script_dir() {
|
get_script_dir() {
|
||||||
src="$0"
|
script="$1"
|
||||||
dir=$(cd -P "$(dirname "$src")" >/dev/null 2>&1 && pwd)
|
case "$script" in
|
||||||
echo "$dir"
|
/*) abs_path="$script" ;;
|
||||||
|
*) abs_path="$PWD/$script" ;;
|
||||||
|
esac
|
||||||
|
while [ -L "$abs_path" ]; do
|
||||||
|
link=$(readlink "$abs_path")
|
||||||
|
case "$link" in
|
||||||
|
/*) abs_path="$link" ;;
|
||||||
|
*) abs_path="$(dirname "$abs_path")/$link" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
script_dir=$(dirname "$abs_path")
|
||||||
|
cd "$script_dir" 2>/dev/null && pwd
|
||||||
}
|
}
|
||||||
MYDIR=$(get_script_dir)
|
|
||||||
. $MYDIR/rbk_api.conf
|
MYDIR=$(get_script_dir "$_SCRIPT_")
|
||||||
|
. $MYDIR/rubrik.conf
|
||||||
. $MYDIR/oracle_funcs.ksh
|
. $MYDIR/oracle_funcs.ksh
|
||||||
|
|
||||||
usage() {
|
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
|
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
|
case "${o}" in
|
||||||
d)
|
d)
|
||||||
DBNAME=${OPTARG}
|
DBNAME=${OPTARG}
|
||||||
@@ -37,6 +59,9 @@ while getopts "d:v:o:" o; do
|
|||||||
o)
|
o)
|
||||||
OPCODE=${OPTARG}
|
OPCODE=${OPTARG}
|
||||||
;;
|
;;
|
||||||
|
n)
|
||||||
|
MVNAME=${OPTARG}
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
@@ -44,20 +69,36 @@ while getopts "d:v:o:" o; do
|
|||||||
done
|
done
|
||||||
shift $((OPTIND-1))
|
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
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Script starts here
|
# Script starts here
|
||||||
|
|
||||||
get_short_hostname() {
|
get_short_hostname() {
|
||||||
if hostname -s >/dev/null 2>&1; then
|
# Check OS type first - HP-UX hostname doesn't support -s
|
||||||
hostname -s
|
os_type=$(uname -s)
|
||||||
else
|
if [ "$os_type" = "HP-UX" ]; then
|
||||||
hostname | awk -F. '{print $1}'
|
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
|
fi
|
||||||
}
|
}
|
||||||
mv_name=$(get_short_hostname)_${DBNAME}_${VOLUME}
|
|
||||||
get_mv
|
get_mv
|
||||||
|
|
||||||
case $OPCODE in
|
case $OPCODE in
|
||||||
|
|||||||
Reference in New Issue
Block a user