107 lines
3.6 KiB
Bash
107 lines
3.6 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Example API call script for Die Mobiliar
|
|
# v0.2 - James Pattinson - June 2022
|
|
#
|
|
# Shows the current settings for an Oracle DB
|
|
#
|
|
# usage: oracle_get_config.sh <HOSTNAME> <CDBNAME>
|
|
# -----------------------------------------------------------------------------
|
|
# Version: Autor: Date: Descrpition:
|
|
# -------- ------ ----- ------------
|
|
# 1.0.0.0 James 04.07.23 Create
|
|
# 1.0.0.1 U701053 09.06.23 add Section size
|
|
# 1.0.0.2 U701053 19.06.23 add the onformations for porepo1
|
|
# -----------------------------------------------------------------------------
|
|
MYDIR="$(dirname "$(realpath "$0")")"
|
|
#source $MYDIR/rbk_api.conf
|
|
source $MYDIR/oracle_funcs.sh
|
|
|
|
usage() { echo ""; echo "Usage: $0 [-c for porepo1] [-h <dbhost>] <SID> "; echo "" 1>&2; exit 1; }
|
|
CATALOG=no
|
|
dg=0
|
|
|
|
while getopts "ch:" o; do
|
|
case "${o}" in
|
|
c)
|
|
CATALOG=yes
|
|
;;
|
|
h)
|
|
RBK_HOST=${OPTARG}
|
|
;;
|
|
*)
|
|
usage
|
|
;;
|
|
esac
|
|
done
|
|
shift $((OPTIND-1))
|
|
|
|
RBK_SID=$1
|
|
|
|
if [ -z "${RBK_SID}" ]; then
|
|
usage
|
|
fi
|
|
|
|
if [ $dg -eq 1 ] && [ ! -z ${RBK_HOST+x} ]; then
|
|
echo "FATAL: Can't specify a host when targing a DG Group"
|
|
exit_with_error
|
|
fi
|
|
|
|
echo Connecting to Rubrik with IP $RUBRIK_IP
|
|
|
|
find_database
|
|
|
|
# API call to list Oracle DB detail
|
|
ENDPOINT=https://$RUBRIK_IP/api/v1/oracle/db/$db_id
|
|
rest_api_get
|
|
|
|
# Reads the parts we need
|
|
sla_name=$(cat /tmp/rbkresponse.$$ | jq -r '.effectiveSlaDomainName')
|
|
echo "Original SLA-Name: ${sla_name}"
|
|
sla_name=${sla_name%' (Managed by Polaris)'}
|
|
|
|
read id dbUniqueName channels log_freq log_retn host_retn section_Size_Gb < <(echo $(cat /tmp/rbkresponse.$$ | jq -r '.id, .dbUniqueName, .numChannels, .logBackupFrequencyInMinutes, .logRetentionHours, .hostLogRetentionHours, .sectionSizeInGb'))
|
|
# echo "channels: $channels, log_freq: $log_freq, log_retn: $log_retn, host_retn: $host_retn, Sectio size: $section_Size_Gb Gb"
|
|
|
|
#echo "rbkresponse /tmp/rbkresponse.$$"
|
|
#echo "================================================"
|
|
#cat /tmp/rbkresponse.$$
|
|
#echo "================================================"
|
|
ENDPOINT=https://$RUBRIK_IP/api/v2/sla_domain/$sla_id
|
|
rest_api_get
|
|
|
|
read dailyretn monthlyretn starthr startmin < <(echo $(cat /tmp/rbkresponse.$$ | jq -r '.frequencies.daily.retention, .frequencies.monthly.retention, .allowedBackupWindows[].startTimeAttributes.hour, .allowedBackupWindows[].startTimeAttributes.minutes'))
|
|
|
|
#echo "================================================"
|
|
#cat /tmp/rbkresponse.$$
|
|
#echo "================================================"
|
|
echo
|
|
echo Protection Details for $RBK_SID on $RBK_HOST
|
|
echo SLA Name: $sla_name
|
|
echo SLA Daily Retention: $dailyretn days
|
|
echo SLA Monthly Retention: $monthlyretn months
|
|
printf "SLA Backup Window: %02d:%02d\n" $starthr $startmin
|
|
echo SLA Log Backup Frequency: $log_freq minutes
|
|
echo SLA Log Backup Retention: $log_retn hours
|
|
if [ $host_retn -eq -2 ]; then
|
|
echo SLA Keep logs on host: Skip Deletion
|
|
elif [ $host_retn -eq -1 ]; then
|
|
echo SLA Keep logs on host: None, deleted immediately
|
|
else
|
|
echo SLA Keep logs on host: $host_retn hours
|
|
fi
|
|
echo Section size: $section_Size_Gb Gb
|
|
echo Channels: $channels
|
|
|
|
if [ "${CATALOG}" = "yes" ] ; then
|
|
if [ "$monthlyretn" = "null" ] ; then
|
|
monthlyretn=""
|
|
fi
|
|
if [ "$dailyretn" = "null" ] ; then
|
|
dailyretn=""
|
|
fi
|
|
echo "DETAILS-SLA:$RBK_SID;$(printf "%-12s\n" `hostname -s`);$id;$RBK_HOST;`printf "%-17s\n" $dbUniqueName`;`printf "%-22s\n" $sla_name`;$dailyretn;$monthlyretn;`printf "%02d:%02d\n" $starthr $startmin`;$log_freq;$log_retn;$host_retn;$section_Size_Gb;$channels"
|
|
fi
|
|
cleanup
|
|
|