Add README and PDB support
This commit is contained in:
35
README.md
35
README.md
@@ -0,0 +1,35 @@
|
||||
# Oracle Clone Script
|
||||
|
||||
This script (`oracle_clone.sh`) performs a clone of an Oracle database using the Rubrik CDM API.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
./oracle_clone.sh [options] <srcSID> <tgtHOSTNAME>
|
||||
```
|
||||
|
||||
- `<srcSID>`: Source Oracle database SID.
|
||||
- `<tgtHOSTNAME>`: Target hostname for the clone.
|
||||
|
||||
## Options
|
||||
|
||||
- `-h <dbhost>` Source DB hostname
|
||||
- `-t <timestamp>` Recovery point timestamp (`"YYYY-MM-DD HH:MM:SS"`, uses latest if not specified)
|
||||
- `-n <newsid>` New database SID for the clone
|
||||
- `-p <pfilepath>` Custom pfile for the clone
|
||||
- `-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)
|
||||
- `-d` Dry run mode - show API payload without executing
|
||||
|
||||
## Notes
|
||||
|
||||
- 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.
|
||||
|
||||
## Example
|
||||
|
||||
```bash
|
||||
./oracle_clone.sh -h dbhost01 -t "2024-06-01 12:00:00" -n CLONE01 -b PDB1,PDB2 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`.
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
# -n <newsid> New database SID for the clone
|
||||
# -p <pfilepath> Custom pfile for the clone
|
||||
# -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)
|
||||
# -d Dry run mode - show API payload without executing
|
||||
#
|
||||
# Time is passed to 'date' on THIS machine, will use local timezone
|
||||
@@ -26,13 +27,15 @@ usage() { echo "Usage: $0 [options] <srcSID> <tgtHOSTNAME>" 1>&2
|
||||
echo " -n <newsid> New database SID for 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 " -b <pdb1,pdb2> Comma-separated list of PDBs to clone (include only these PDBs)" 1>&2
|
||||
echo " -d Dry run mode" 1>&2
|
||||
exit 1; }
|
||||
|
||||
declare -a config_pairs
|
||||
declare -a pdb_list
|
||||
dryrun=false
|
||||
|
||||
while getopts "h:dt:n:p:a:" o; do
|
||||
while getopts "h:dt:n:p:a:b:" o; do
|
||||
case "${o}" in
|
||||
h)
|
||||
RBK_HOST=${OPTARG}
|
||||
@@ -49,6 +52,9 @@ while getopts "h:dt:n:p:a:" o; do
|
||||
a)
|
||||
config_pairs+=("${OPTARG}")
|
||||
;;
|
||||
b)
|
||||
IFS=',' read -ra pdb_list <<< "${OPTARG}"
|
||||
;;
|
||||
d)
|
||||
dryrun=true
|
||||
;;
|
||||
@@ -123,6 +129,16 @@ if [ -n "$custompfile" ]; then
|
||||
PAYLOAD="$PAYLOAD,\"customPfilePath\":\"$custompfile\""
|
||||
fi
|
||||
|
||||
# Add pdbsToClone array if -b specified
|
||||
if [ ${#pdb_list[@]} -gt 0 ]; then
|
||||
pdbs_json="\"PDB\$SEED\""
|
||||
for pdb in "${pdb_list[@]}"; do
|
||||
pdbs_json="$pdbs_json,\"$pdb\""
|
||||
done
|
||||
echo "PDB: Including PDBs in clone: PDB\$SEED ${pdb_list[*]}"
|
||||
PAYLOAD="$PAYLOAD,\"pdbsToClone\":[${pdbs_json}]"
|
||||
fi
|
||||
|
||||
PAYLOAD="$PAYLOAD,\"advancedRecoveryConfigMap\":{$configmap}}"
|
||||
|
||||
ENDPOINT="https://$RUBRIK_IP/api/internal/oracle/db/$db_id/export"
|
||||
|
||||
Reference in New Issue
Block a user