From b71ca508ea9d1816c161ba9cef380a785fe8364b Mon Sep 17 00:00:00 2001 From: SupraJames Date: Wed, 15 Oct 2025 17:19:17 +0100 Subject: [PATCH] Add numChannels support --- README.md | 37 +++++++++++++++++++++++++++++++++++++ rbk_api.conf | 4 ---- rsc_clone.sh | 23 ++++++++++++++++++++--- 3 files changed, 57 insertions(+), 7 deletions(-) delete mode 100644 rbk_api.conf diff --git a/README.md b/README.md index d05ea15..7e32172 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ 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 @@ -159,6 +161,41 @@ When multiple databases with the same name exist on different hosts: ## Script Workflow +### Configuration (rsc.json) + +The scripts read RSC credentials and endpoint details from `rsc.json` in the repository root. An example file `rsc.json.example` is included. The expected JSON fields are: + +``` +{ + "client_id": "", + "client_secret": "", + "access_token_uri": "https:///api/client_token", + "name": "" +} +``` + +Security note: `rsc.json` is listed in `.gitignore`. Ensure the file permissions are restricted (recommended `chmod 600 rsc.json`). If `rsc.json` was accidentally committed to git, consider purging it from history. + +### Examples + +- Basic dry-run with verbose output: + +``` +./rsc_clone.sh -n SCLONE -o SHED_to_SCLONE.txt -h pve-ora19c-3 -d -v SHED +``` + +- Execute clone and request 4 RMAN channels: + +``` +./rsc_clone.sh -n SCLONE -o SHED_to_SCLONE.txt -h pve-ora19c-3 -c 4 SHED +``` + +- Trigger an on-demand log backup with verbose logging: + +``` +./rsc_log_backup.sh -v +``` + 1. **Parameter Validation** - Validates required parameters and options file 2. **Database Discovery** - Locates source database in RSC 3. **Host Resolution** - Resolves target host ID in RSC diff --git a/rbk_api.conf b/rbk_api.conf deleted file mode 100644 index 0c87c57..0000000 --- a/rbk_api.conf +++ /dev/null @@ -1,4 +0,0 @@ - -RSC_HOST=rubrik-rbkpso20.my.rubrik.com -RSC_ID="client|673af632-150d-47e0-908e-66a6d71fe621" -RSC_SECRET=lIHYPGMjmDLf3jflRRHtl1Oqf0YlfY7z0YNdwLG0VetfKuiVkIl_SsD4QAjAhEOb diff --git a/rsc_clone.sh b/rsc_clone.sh index a2c5fe0..4507b7b 100755 --- a/rsc_clone.sh +++ b/rsc_clone.sh @@ -5,7 +5,7 @@ # # Perfoms a database clone operation # -# usage: rsc_clone.sh -n -o -h [-s sourcehost] [-t "YYYY-MM-DD HH:MM:SS"] [-d] +# usage: rsc_clone.sh -n -o -h [-s sourcehost] [-t "YYYY-MM-DD HH:MM:SS"] [-d] [-c numChannels] # # Options: # -n : db_name / SID of the new cloned database @@ -14,6 +14,7 @@ # -s : Source host where the original database is located (optional, use when there is ambiguity) # -t "YYYY-MM-DD HH:MM:SS" : Optional timestamp for the recovery point, defaults to latest PIT # -d : Dry-run mode - show mutation variables without executing the clone +# -c : Optional - number of RMAN channels to configure for the clone # : Source database name or RSC dbid (if known, can be used directly) # # Example options file content: @@ -23,7 +24,7 @@ # DB_CREATE_FILE_DEST=/u01/app/oracle/oradata/NEWNAME/ # AUDIT_FILE_DEST='/u01/app/oracle/admin/NEWNAME/adump' -usage() { log_error "Usage: $0 -n -o -h [-s sourcehost] [-t \"YYYY-MM-DD HH:MM:SS\"] [-d] "; exit 1; } +usage() { log_error "Usage: $0 -n -o -h [-s sourcehost] [-t \"YYYY-MM-DD HH:MM:SS\"] [-d] [-c numChannels] "; exit 1; } MYDIR="$(dirname "$(realpath "$0")")" @@ -39,7 +40,7 @@ done source $MYDIR/rsc_ops.sh -while getopts "n:o:t:h:s:d:v" o; do +while getopts "n:o:t:h:s:d:v:c:" o; do case "${o}" in n) newName=${OPTARG} @@ -62,6 +63,14 @@ while getopts "n:o:t:h:s:d:v" o; do v) VERBOSE=1 ;; + c) + numChannels=${OPTARG} + # Validate numChannels is a positive integer + if ! [[ "$numChannels" =~ ^[0-9]+$ && "$numChannels" -gt 0 ]]; then + log_error "-c requires a positive integer value" + exit_with_error + fi + ;; *) usage ;; @@ -331,12 +340,20 @@ log_info "Target Host ID is $targetHostId" cloningOptions=$(template_to_json $optionsFile) +# Optionally include numChannels in the config +if [[ -n "${numChannels:-}" ]]; then + numChannelsPart="\"numChannels\": $numChannels," +else + numChannelsPart="" +fi + variables=" { \"input\": { \"request\": { \"id\": \"$dbid\", \"config\": { + $numChannelsPart \"targetOracleHostOrRacId\": \"$targetHostId\", \"shouldRestoreFilesOnly\": false, \"recoveryPoint\": {