Compare commits

...

4 Commits

Author SHA1 Message Date
92e53232dc Update README 2025-10-08 04:33:35 -04:00
e583ca1aa0 Update README.md 2025-10-08 04:00:04 -04:00
5debc4cac9 Update README 2025-10-07 08:30:32 -04:00
3b7641ea2c Allow numChannels to be set 2025-10-07 05:20:19 -04:00
2 changed files with 58 additions and 6 deletions

View File

@@ -1,6 +1,8 @@
# Oracle Clone Script # Oracle Clone Script
This script (`oracle_clone.sh`) performs a clone of an Oracle database using the Rubrik CDM API. Created by James Pattinson (Rubrik PS) October 2025 for Die Mobiliar
This script (`oracle_clone.sh`) performs a clone of an Oracle database using the Rubrik CDM API. it integrates with the scripting already present at Die Mobiliar for orchestrating Oracle backup and recovery management.
## Usage ## Usage
@@ -13,23 +15,63 @@ This script (`oracle_clone.sh`) performs a clone of an Oracle database using the
## Options ## Options
- `-h <dbhost>` Source DB hostname - `-h <dbhost>` Source DB hostname (if source SID is not unique)
- `-t <timestamp>` Recovery point timestamp (`"YYYY-MM-DD HH:MM:SS"`, uses latest if not specified) - `-t <timestamp>` Recovery point timestamp (`"YYYY-MM-DD HH:MM:SS"`, uses latest if not specified)
- `-n <newsid>` New database SID for the clone - `-n <newsid>` New database SID for the clone
- `-p <pfilepath>` Custom pfile for the clone - `-p <pfilepath>` Custom pfile for the clone
- `-a <key,value>` Advanced Cloning Options (can be used multiple times) - `-a <key,value>` Advanced Cloning Options (can be used multiple times)
- `-b <pdb1,pdb2>` Comma-separated list of PDBs to clone (include only these PDBs. `PDB$SEED` is always included) - `-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 (sets `numChannels` in the API payload)
- `-d` Dry run mode - show API payload without executing - `-d` Dry run mode - show API payload without executing
## Configuration (`rbk_api.conf`)
Before running the script, you must configure Rubrik API access in the `rbk_api.conf` file (located in the same directory). This file should define the following variables:
- `RUBRIK_IP`: The IP address or DNS name of your Rubrik CDM cluster.
- `ID`: The service account ID or user credential for API authentication.
- `SECRET`: The secret or password for the service account/user.
- `RSC_HOST`: API endpoint host for SLA modification and other GraphQL calls
**Example `rbk_api.conf`:**
```properties
RUBRIK_IP=<cdm IP address>
ID="client|your-service-account-id"
SECRET=your-service-account-secret
RSC_HOST=customername.my.rubrik.com
```
> **Note:** Do not share your `rbk_api.conf` file or secrets publicly.
## Notes ## Notes
- The script requires access to the Rubrik API and expects the supporting functions `oracle_funcs.sh` to be present in the same directory. - The script requires access to the Rubrik API and expects the supporting functions `oracle_funcs.sh` to be present in the same directory.
- Time is passed to `date` on the local machine and uses the local timezone. - Time is passed to `date` on the local machine and uses the local timezone.
- If `-b` is specified, the script will print the list of PDBs included in the clone.
- The `-c` option allows you to specify the number of RMAN channels to use for the clone operation. This is passed as `numChannels` in the API payload.
## Example ## Example
```bash ```bash
./oracle_clone.sh -h dbhost01 -t "2024-06-01 12:00:00" -n CLONE01 -b PDB1,PDB2 orcl targethost ./oracle_clone.sh -h dbhost01 -t "2024-06-01 12:00:00" -n CLONE01 -b PDB1,PDB2 -c 8 orcl targethost
``` ```
This will clone the `orcl` database from `dbhost01` to `targethost`, using the specified timestamp, new SID `CLONE01`, and only include `PDB$SEED`, `PDB1`, and `PDB2`. This will clone the `orcl` database from `dbhost01` to `targethost`, using the specified timestamp, new SID `CLONE01`, only include `PDB$SEED`, `PDB1`, and `PDB2`, and use 8 RMAN channels for the operation.
```bash
./oracle_clone.sh -n CLNONE -a AUDIT_FILE_DEST,/u01/app/oracle/admin/CLNONE/adump \
-a DB_FILE_NAME_CONVERT,"'SHED','CLNONE'" -a DB_CREATE_FILE_DEST,/u01/app/oracle/oradata/CLNONE/ \
-a CONTROL_FILES,"'/u01/app/oracle/oradata/CLNONE/control01.ctl, /u01/app/oracle/fast_recovery_area/CLNONE/control02.ctl'" \
-b PDBXYZ,PDBABC SHED pve-ora19c-3
```
Uses the latest available Point-in-Time of the source `SHED` and clones to a new database `CLNONE` on the target host `pve-ora19c-3`. The Advanced Cloning Options are present:
```
AUDIT_FILE_DEST = /u01/app/oracle/admin/CLNONE/adump
DB_FILE_NAME_CONVERT = 'SHED','CLNONE'
DB_CREATE_FILE_DEST = /u01/app/oracle/oradata/CLNONE/
CONTROL_FILES = '/u01/app/oracle/oradata/CLNONE/control01.ctl, /u01/app/oracle/fast_recovery_area/CLNONE/control02.ctl'
```
Additionally, only PDBs `PDBXYZ` and `PDBABC` will be cloned.

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Perform a Clone of an Oracle DB # Perform a Clone of an Oracle DB
# v1.0 - James Pattinson - October 2025 # v1.2 - James Pattinson - October 2025
# #
# usage: oracle_clone.sh [options] <srcSID> <tgtHOSTNAME> # usage: oracle_clone.sh [options] <srcSID> <tgtHOSTNAME>
# #
@@ -12,6 +12,7 @@
# -p <pfilepath> Custom pfile for the clone # -p <pfilepath> Custom pfile for the clone
# -a <key,value> Advanced Cloning Options (can be used multiple times) # -a <key,value> Advanced Cloning Options (can be used multiple times)
# -b <pdb1,pdb2> Comma-separated list of PDBs to clone (include only these PDBs. PDB$SEED is always included) # -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 # -d Dry run mode - show API payload without executing
# #
# Time is passed to 'date' on THIS machine, will use local timezone # Time is passed to 'date' on THIS machine, will use local timezone
@@ -28,6 +29,7 @@ usage() { echo "Usage: $0 [options] <srcSID> <tgtHOSTNAME>" 1>&2
echo " -p <pfilepath> Custom pfile for the clone" 1>&2 echo " -p <pfilepath> Custom pfile for the clone" 1>&2
echo " -a <key,value> Advanced Cloning Options (can be used multiple times)" 1>&2 echo " -a <key,value> Advanced Cloning Options (can be used multiple times)" 1>&2
echo " -b <pdb1,pdb2> Comma-separated list of PDBs to clone (include only these PDBs)" 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 " -d Dry run mode" 1>&2
exit 1; } exit 1; }
@@ -35,7 +37,8 @@ declare -a config_pairs
declare -a pdb_list declare -a pdb_list
dryrun=false dryrun=false
while getopts "h:dt:n:p:a:b:" o; do num_channels=""
while getopts "h:dt:n:p:a:b:c:" o; do
case "${o}" in case "${o}" in
h) h)
RBK_HOST=${OPTARG} RBK_HOST=${OPTARG}
@@ -55,6 +58,9 @@ while getopts "h:dt:n:p:a:b:" o; do
b) b)
IFS=',' read -ra pdb_list <<< "${OPTARG}" IFS=',' read -ra pdb_list <<< "${OPTARG}"
;; ;;
c)
num_channels=${OPTARG}
;;
d) d)
dryrun=true dryrun=true
;; ;;
@@ -129,6 +135,10 @@ if [ -n "$custompfile" ]; then
PAYLOAD="$PAYLOAD,\"customPfilePath\":\"$custompfile\"" PAYLOAD="$PAYLOAD,\"customPfilePath\":\"$custompfile\""
fi fi
if [ -n "$num_channels" ]; then
PAYLOAD="$PAYLOAD,\"numChannels\":$num_channels"
fi
# Add pdbsToClone array if -b specified # Add pdbsToClone array if -b specified
if [ ${#pdb_list[@]} -gt 0 ]; then if [ ${#pdb_list[@]} -gt 0 ]; then
pdbs_json="\"PDB\$SEED\"" pdbs_json="\"PDB\$SEED\""