#!/bin/bash # # Example API call script for Die Mobiliar # v0.2 - James Pattinson - August 2021 # # Lists the registered DBs for a given Oracle Host or RAC # and their assigned SLAs # # usage: oracle_list_db.sh MYDIR="$(dirname "$(realpath "$0")")" # source $MYDIR/rbk_api.conf source $MYDIR/oracle_funcs.sh usage() { echo "Usage: $0 [-h ] [-g|] " 1>&2; exit 1; } while getopts "h:" o; do case "${o}" in h) RBK_HOST=${OPTARG} ;; *) usage ;; esac done shift $((OPTIND-1)) RBK_SID=$1 if [ -z "${RBK_SID}" ]; then usage fi echo Connecting to Rubrik with IP $RUBRIK_IP # API call to list Oracle DBs find_database echo Fetching available snapshots for $RBK_SID on $RBK_HOST # API call to get the recoverable range ENDPOINT="https://$RUBRIK_IP/api/internal/oracle/db/$db_id/snapshot" rest_api_get echo echo -e "Sid\t\tDate Taken\t\t\tOn Demand\tFreq\tSLA Name\t\treplication" echo -e "--------\t----------\t\t\t---------\t-----\t----------\t\t-----------" cat /tmp/rbkresponse.$$ | jq -r '.data | sort_by(.date) | .[] | "\(.databaseName)\t\(.date)\t\(.isOnDemandSnapshot)\t\t\(.snapshotRetentionInfo.localInfo.snapshotFrequency)\t\(.slaName)\t\(.snapshotRetentionInfo.replicationInfos[0].id)\t\(.snapshotRetentionInfo.replicationInfos[0].name)"' cleanup