diff --git a/README.md b/README.md index 7e32172..31d677f 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,6 @@ DB_FILE_NAME_CONVERT='SHED','SCLONE' - `-s ` - Source host name (use when there are multiple databases with the same name on different hosts) - `-t "YYYY-MM-DD HH:MM:SS"` - Recovery point timestamp (defaults to latest point-in-time) - `-d` - Dry-run mode (shows mutation variables without executing) -- `-v` or `--verbose` - Enable verbose logging (prints INFO lines and debug context) - `-c ` - Optional: configure number of RMAN channels for the clone; when provided the script adds `"numChannels": ` to the `config` block in the GraphQL variables ## Examples @@ -181,7 +180,7 @@ Security note: `rsc.json` is listed in `.gitignore`. Ensure the file permissions - Basic dry-run with verbose output: ``` -./rsc_clone.sh -n SCLONE -o SHED_to_SCLONE.txt -h pve-ora19c-3 -d -v SHED +./rsc_clone.sh -n SCLONE -o SHED_to_SCLONE.txt -h pve-ora19c-3 -d SHED ``` - Execute clone and request 4 RMAN channels: @@ -193,7 +192,7 @@ Security note: `rsc.json` is listed in `.gitignore`. Ensure the file permissions - Trigger an on-demand log backup with verbose logging: ``` -./rsc_log_backup.sh -v +./rsc_log_backup.sh ``` 1. **Parameter Validation** - Validates required parameters and options file diff --git a/rsc_clone.sh b/rsc_clone.sh index 4507b7b..7563cc2 100755 --- a/rsc_clone.sh +++ b/rsc_clone.sh @@ -28,16 +28,6 @@ usage() { log_error "Usage: $0 -n -o -h [-s MYDIR="$(dirname "$(realpath "$0")")" -# Support long option --verbose by translating to -v before getopts -for arg in "$@"; do - case "$arg" in - --verbose) - set -- "${@/--verbose/-v}" - break - ;; - esac -done - source $MYDIR/rsc_ops.sh while getopts "n:o:t:h:s:d:v:c:" o; do @@ -60,9 +50,6 @@ while getopts "n:o:t:h:s:d:v:c:" o; do d) dryrun=true ;; - v) - VERBOSE=1 - ;; c) numChannels=${OPTARG} # Validate numChannels is a positive integer diff --git a/rsc_host_refresh.sh b/rsc_host_refresh.sh index e00899b..bb47d2c 100755 --- a/rsc_host_refresh.sh +++ b/rsc_host_refresh.sh @@ -10,7 +10,7 @@ # Options: # : Host to perform refresh job -usage() { log_error "Usage: $0 "; exit 1; } +usage() { echo "Usage: $0 " >&2; exit 1; } if [[ -z "$1" ]]; then usage @@ -18,19 +18,7 @@ fi MYDIR="$(dirname "$(realpath "$0")")" -# Support -v/--verbose and strip it from positional args -NEWARGS=() -for arg in "$@"; do - case "$arg" in - -v|--verbose) - VERBOSE=1 - ;; - *) - NEWARGS+=("$arg") - ;; - esac -done -set -- "${NEWARGS[@]}" +# No verbose flag: log_info prints by default source $MYDIR/rsc_ops.sh diff --git a/rsc_list_oracle_slas.sh b/rsc_list_oracle_slas.sh index 2e4e330..3a3b057 100755 --- a/rsc_list_oracle_slas.sh +++ b/rsc_list_oracle_slas.sh @@ -7,22 +7,10 @@ # # usage: rsc_list_slas.sh [filter] -usage() { log_error "Usage: $0 [filter]"; exit 1; } +usage() { echo "Usage: $0 [filter]" >&2; exit 1; } MYDIR="$(dirname "$(realpath "$0")")" -# Support -v/--verbose and strip it from positional args so it doesn't become $1 -NEWARGS=() -for arg in "$@"; do - case "$arg" in - -v|--verbose) - VERBOSE=1 - ;; - *) - NEWARGS+=("$arg") - ;; - esac -done -set -- "${NEWARGS[@]}" +# log_info prints by default now; no verbose flag # source $MYDIR/rbk_api.conf source $MYDIR/rsc_ops.sh diff --git a/rsc_log_backup.sh b/rsc_log_backup.sh index 77e2b8c..6b4d83c 100755 --- a/rsc_log_backup.sh +++ b/rsc_log_backup.sh @@ -7,7 +7,7 @@ # # usage: rsc_log_backup.sh [filter] -usage() { log_error "Usage: $0 [filter]"; exit 1; } +usage() { echo "Usage: $0 [filter]" >&2; exit 1; } if [[ -z "$1" ]]; then usage @@ -15,19 +15,7 @@ fi MYDIR="$(dirname "$(realpath "$0")")" -# Support -v/--verbose and strip it from positional args -NEWARGS=() -for arg in "$@"; do - case "$arg" in - -v|--verbose) - VERBOSE=1 - ;; - *) - NEWARGS+=("$arg") - ;; - esac -done -set -- "${NEWARGS[@]}" +# log_info prints by default now; no verbose flag # source $MYDIR/rbk_api.conf source $MYDIR/rsc_ops.sh diff --git a/rsc_ops.sh b/rsc_ops.sh index 87f88bd..dfdccc1 100755 --- a/rsc_ops.sh +++ b/rsc_ops.sh @@ -10,11 +10,8 @@ MYDIR="$(dirname "$(realpath "$0")")" # Logging helpers -VERBOSE=${VERBOSE:-0} log_info() { - if [ "${VERBOSE}" -eq 1 ]; then - echo "INFO: $*" - fi + echo "INFO: $*" } log_warn() { echo "WARN: $*" >&2 @@ -219,12 +216,21 @@ rsc_get_host_id() { # Get all matching host IDs (portable, no mapfile) host_ids=$(cat /tmp/rbkresponse.$$ | jq -r '.data.physicalHosts.nodes[] | .id') host_count=$(echo "$host_ids" | grep -c .) - if [[ $host_count -ne 1 ]]; then - log_error "Multiple hosts found for '$1':" - cat /tmp/rbkresponse.$$ | jq -r '.data.physicalHosts.nodes[] | "\(.name) \(.id)"' + + if [[ $host_count -eq 0 ]]; then + log_error "Host '$RBK_HOST' not found by exact match (this script requires an exact host name)." + log_error "Please re-run with the exact host name as stored in RSC." exit_with_error fi - # Set the first match (or empty if none) + + if [[ $host_count -gt 1 ]]; then + log_error "Multiple hosts found for '$RBK_HOST':" + cat /tmp/rbkresponse.$$ | jq -r '.data.physicalHosts.nodes[] | "\(.name) \(.id)"' + log_error "Please re-run with the exact host name to disambiguate." + exit_with_error + fi + + # Exactly one match: set the first match targetHostId=$(echo "$host_ids" | head -n 1) #cat /tmp/rbkresponse.$$ | jq -r