Add logging

This commit is contained in:
2025-10-16 05:45:19 -04:00
parent fb892c13ed
commit fedecacd0b
5 changed files with 158 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
#!/bin/bash
ORIG_ARGS="$*"
#
# Perform a Clone of an Oracle DB
# v1.3 - James Pattinson - October 2025
@@ -14,12 +15,29 @@
# -b <pdb1,pdb2> Comma-separated list of PDBs to clone (include only these PDBs. PDB$SEED is always included)
# -c <channels> Number of RMAN channels to use
# -d Dry run mode - show API payload without executing
# -l <logfile> Log all API calls (endpoints, payloads, responses) to <logfile>
# --refresh Refresh target database before cloning (if it exists)
#
# Time is passed to 'date' on THIS machine, will use local timezone
MYDIR="$(dirname "$(realpath "$0")")"
# source $MYDIR/rbk_api.conf
# Argument parsing and RBK_API_LOG assignment happens below
# After argument parsing, write the log header if enabled
# Debugging: Confirm if log header code is executed
if [ -n "$RBK_API_LOG" ]; then
echo "Debug: Writing log header to $RBK_API_LOG" >> /tmp/debug_oracle_clone.log
export RBK_API_LOG
{
echo "==== Rubrik Oracle Clone Log ===="
date
echo "Script: $0"
echo "Parameters: $ORIG_ARGS"
echo
} >> "$RBK_API_LOG"
fi
source $MYDIR/oracle_funcs.sh
# Set up cleanup trap to ensure temporary files are removed
@@ -35,6 +53,7 @@ usage() { echo "Usage: $0 [options] <srcSID> <tgtHOSTNAME>" 1>&2
echo " -b <pdb1,pdb2> Comma-separated list of PDBs to clone (include only these PDBs)" 1>&2
echo " -c <channels> Number of RMAN channels to use" 1>&2
echo " -d Dry run mode" 1>&2
echo " -l <logfile> Log all API calls (endpoints, payloads, responses) to <logfile>" 1>&2
echo " --refresh Refresh target database before cloning (if it exists)" 1>&2
exit 1; }
@@ -59,7 +78,8 @@ for arg in "$@"; do
done
set -- "${args[@]}"
while getopts "h:dt:n:p:a:b:c:" o; do
RBK_API_LOG=""
while getopts "h:dt:n:p:a:b:c:l:" o; do
case "${o}" in
h)
RBK_HOST=${OPTARG}
@@ -79,6 +99,9 @@ while getopts "h:dt:n:p:a:b:c:" o; do
b)
IFS=',' read -ra pdb_list <<< "${OPTARG}"
;;
l)
RBK_API_LOG="${OPTARG}"
;;
c)
num_channels=${OPTARG}
;;