Add numChannels support
This commit is contained in:
37
README.md
37
README.md
@@ -58,6 +58,8 @@ DB_FILE_NAME_CONVERT='SHED','SCLONE'
|
||||
- `-s <sourcehost>` - 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 <numChannels>` - Optional: configure number of RMAN channels for the clone; when provided the script adds `"numChannels": <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": "<your-client-id>",
|
||||
"client_secret": "<your-client-secret>",
|
||||
"access_token_uri": "https://<rsc-host>/api/client_token",
|
||||
"name": "<optional-friendly-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 <dbName>
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
RSC_HOST=rubrik-rbkpso20.my.rubrik.com
|
||||
RSC_ID="client|673af632-150d-47e0-908e-66a6d71fe621"
|
||||
RSC_SECRET=lIHYPGMjmDLf3jflRRHtl1Oqf0YlfY7z0YNdwLG0VetfKuiVkIl_SsD4QAjAhEOb
|
||||
23
rsc_clone.sh
23
rsc_clone.sh
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# Perfoms a database clone operation
|
||||
#
|
||||
# usage: rsc_clone.sh -n <newname> -o <optionsfile> -h <targethost> [-s sourcehost] [-t "YYYY-MM-DD HH:MM:SS"] [-d] <srcdb>
|
||||
# usage: rsc_clone.sh -n <newname> -o <optionsfile> -h <targethost> [-s sourcehost] [-t "YYYY-MM-DD HH:MM:SS"] [-d] [-c numChannels] <srcdb>
|
||||
#
|
||||
# Options:
|
||||
# -n <newname> : db_name / SID of the new cloned database
|
||||
@@ -14,6 +14,7 @@
|
||||
# -s <sourcehost> : 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 <numChannels> : Optional - number of RMAN channels to configure for the clone
|
||||
# <srcdb> : 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 <newname> -o <optionsfile> -h <targethost> [-s sourcehost] [-t \"YYYY-MM-DD HH:MM:SS\"] [-d] <srcdb>"; exit 1; }
|
||||
usage() { log_error "Usage: $0 -n <newname> -o <optionsfile> -h <targethost> [-s sourcehost] [-t \"YYYY-MM-DD HH:MM:SS\"] [-d] [-c numChannels] <srcdb>"; 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\": {
|
||||
|
||||
Reference in New Issue
Block a user