Adding original DM files

This commit is contained in:
2025-10-03 10:15:23 -04:00
parent 1508078efb
commit bc30f7b788
31 changed files with 2818 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
#!/bin/bash
#
# Example API call script for Die Mobiliar
# v0.3 - James Pattinson - June 2022
#
# Set the backup settings for a given Oracle DB
#
# usage: oracle_set_config.sh <HOSTNAME> <CDBNAME> <log freq (mins)> <log retn (hours)> <host retn (hours)> <channels>
#
# Log backup of 0 disables log backup
# host retention of -1 disables host log retention
MYDIR="$(dirname "$(realpath "$0")")"
# source $MYDIR/rbk_api.conf
source $MYDIR/oracle_funcs_new.sh
usage() { echo "Usage: $0 -s <sla name> -f <log freq (mins)> -r <log retn (days)> -h <host retn (hours)>" 1>&2; echo ""; exit 1; }
dg=0
while getopts "s:f:r:h:" o; do
case "${o}" in
s)
RBK_SLA=${OPTARG}
;;
f)
log_freq=${OPTARG}
;;
r)
log_retn=${OPTARG}
;;
h)
host_retn=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
#RBK_SLA=$1
if [ -z "${RBK_SLA}" ] || [ -z "${log_freq}" ] || [ -z "${log_retn}" ] || [ -z "${host_retn}" ]; then
echo ""
usage
echo ""
fi
#log_freq=$2
#log_retn=$3
#host_retn=$4
echo Connecting to Rubrik with IP $RUBRIK_IP
# Encode the SLA name for curl
RBK_SLA_SAFE=$(printf %s "${RBK_SLA}" |jq -sRr @uri)
# API call to list SLAs
ENDPOINT=https://$RUBRIK_IP/api/v1/sla_domain?name=$RBK_SLA_SAFE
rest_api_get
total=$(cat /tmp/rbkresponse.$$ | jq -r '.total')
if [ $total -ne 1 ]; then
echo SLA not found, or more than one SLA matches input of \"$RBK_SLA\"
echo Please run again and specify one of:
cat /tmp/rbkresponse.$$ | jq -r '.data[].name'
exit_with_error
fi
sla_id=$(cat /tmp/rbkresponse.$$ | jq -r '.data[0].id')
# API call to set configuration
#PAYLOAD={\"logBackupFrequencyInMinutes\":$log_freq,\"logRetentionHours\":$log_retn,\"hostLogRetentionHours\":$host_retn,\"numChannels\":$channels}
#PAYLOAD={\"numChannels\":$channels,\"hasLogConfigFromSla\":true}
((logrtn_min = $log_retn * 60 * 24))
if [ $host_retn -gt 0 ]; then
((hostrtn_min = $host_retn * 60))
else
hostrtn_min=$host_retn
fi
echo "titi"
ENDPOINT=https://$RUBRIK_IP/api/v2/sla_domain/${sla_id}?should_apply_to_existing_snapshots=false&should_apply_to_non_policy_snapshots=false
echo "titi"
PAYLOAD="{\"logConfig\":{},\"logConfigs\":{\"OracleDatabase\":{\"slaLogFrequencyConfig\":{\"logFrequencyType\":\"Minute\",\"retention\":$logrtn_min,\"freqency\":$log_freq},\"hostLogRetentionInMinutes\":$hostrtn_min}}}"
echo "titi"
rest_api_patch
echo "titi"
echo New configuration for $RBK_SID on $RBK_HOST is set
cleanup