Files
llb-oracle/README.md

210 lines
5.8 KiB
Markdown

# RSC Oracle Database Clone Script
## Overview
The `rsc_clone.sh` script performs Oracle database clone operations using the Rubrik Security Cloud (RSC) GraphQL API. It allows you to create a clone of an existing Oracle database to a target host with customizable recovery points and advanced Oracle configuration options.
## Prerequisites
- Rubrik Security Cloud (RSC) access with valid credentials
- Source Oracle database protected by Rubrik
- Target Oracle host configured and registered in RSC
- Required configuration files:
- `rbk_api.conf` - RSC API credentials
- Oracle cloning options file
## Configuration
### RSC API Configuration (`rbk_api.conf`)
Create a configuration file with your RSC credentials:
```bash
# Rubrik Security Cloud (RSC) Configuration
RSC_HOST=your-organization.my.rubrik.com
RSC_ID="client|your-client-id-here"
RSC_SECRET=your-secret-key-here
```
### Oracle Cloning Options File
Create a text file with Oracle-specific cloning parameters. Each line should contain `KEY=VALUE` pairs for Oracle initialization parameters:
```bash
# Example: SHED_to_SCLONE.txt
CONTROL_FILES='/u01/app/oracle/oradata/SCLONE/control01.ctl, /u01/app/oracle/fast_recovery_area/SCLONE/control02.ctl'
DB_CREATE_FILE_DEST=/u01/app/oracle/oradata/SCLONE/
AUDIT_FILE_DEST='/u01/app/oracle/admin/SCLONE/adump'
DB_FILE_NAME_CONVERT='SHED','SCLONE'
```
## Usage
```bash
./rsc_clone.sh -n <newname> -o <optionsfile> -h <targethost> [-s sourcehost] [-t "YYYY-MM-DD HH:MM:SS"] [-d] <srcdb>
```
### Required Parameters
- `-n <newname>` - Database name/SID for the cloned database
- `-o <optionsfile>` - Path to Oracle cloning options file
- `-h <targethost>` - Target host where the database will be cloned
- `<srcdb>` - Source database name to clone
### Optional Parameters
- `-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)
## Examples
### Basic Clone Operation
Clone database `SHED` to `SCLONE` on target host `pve-ora19c-3`:
```bash
./rsc_clone.sh -n SCLONE -o SHED_to_SCLONE.txt -h pve-ora19c-3 SHED
```
### Dry-Run Mode
Preview the clone operation without executing it:
```bash
./rsc_clone.sh -n SCLONE -o SHED_to_SCLONE.txt -h pve-ora19c-3 -d SHED
```
**Output:**
```
DEBUG: DB ID is b4194205-b7d6-5f0b-8360-e6f349b9fd82
INFO: No time specified, using latest PIT
Latest PIT (ISO8601): 2025-10-15T08:32:49.000Z
Latest PIT unixtime (ms): 1760517169000
Target Host ID is 26008fd4-9a96-582e-86b7-4da31584a7ad
=== DRY-RUN MODE ===
Would execute the following GraphQL mutation:
QUERY:
mutation OracleDatabaseExportMutation($input: ExportOracleDatabaseInput!) {
exportOracleDatabase(input: $input) {
id
links {
href
rel
__typename
}
__typename
}
}
VARIABLES:
{
"input": {
"request": {
"id": "b4194205-b7d6-5f0b-8360-e6f349b9fd82",
"config": {
"targetOracleHostOrRacId": "26008fd4-9a96-582e-86b7-4da31584a7ad",
"shouldRestoreFilesOnly": false,
"recoveryPoint": {
"timestampMs": 1760517169000
},
"cloneDbName": "SCLONE",
"shouldAllowRenameToSource": true,
"shouldSkipDropDbInUndo": false
}
},
"advancedRecoveryConfigMap": [
{
"key": "CONTROL_FILES",
"value": "'/u01/app/oracle/oradata/SCLONE/control01.ctl, /u01/app/oracle/fast_recovery_area/SCLONE/control02.ctl'"
},
{
"key": "DB_CREATE_FILE_DEST",
"value": "/u01/app/oracle/oradata/SCLONE/"
},
{
"key": "AUDIT_FILE_DEST",
"value": "'/u01/app/oracle/admin/SCLONE/adump'"
},
{
"key": "DB_FILE_NAME_CONVERT",
"value": "'SHED','SCLONE'"
}
]
}
}
=== END DRY-RUN ===
```
### Point-in-Time Recovery
Clone database to a specific point in time:
```bash
./rsc_clone.sh -n SCLONE -o SHED_to_SCLONE.txt -h pve-ora19c-3 -t "2025-10-15 08:00:00" SHED
```
### Specify Source Host
When multiple databases with the same name exist on different hosts:
```bash
./rsc_clone.sh -n SCLONE -o SHED_to_SCLONE.txt -h pve-ora19c-3 -s pve-ora19c-1 SHED
```
## Script Workflow
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
4. **Recovery Point** - Determines recovery timestamp (latest or specified)
5. **Options Processing** - Converts options file to JSON format
6. **Clone Execution** - Submits GraphQL mutation to RSC API
7. **Job Monitoring** - Tracks clone job status until completion
## Error Handling
The script includes comprehensive error handling for:
- Missing required parameters
- Database not found or ambiguous matches
- Target host not found
- Invalid recovery timestamps
- RSC API errors
- Job failures
## Dependencies
- `rsc_ops.sh` - RSC API operations and utility functions
- `rbk_api.conf` - RSC credentials configuration
- `jq` - JSON processing
- `curl` - HTTP requests
- `date`/`gdate` - Date/time operations
## Troubleshooting
### Common Issues
1. **Database not found** - Verify database name and use `-s` if multiple databases exist
2. **Host not found** - Check target host name is registered in RSC
3. **Permission errors** - Ensure RSC service account has sufficient privileges
4. **Invalid timestamp** - Use format "YYYY-MM-DD HH:MM:SS" for `-t` parameter
### Debug Information
The script provides debug output including:
- Source database ID
- Target host ID
- Recovery point details
- Job status updates
Use dry-run mode (`-d`) to validate configuration before executing actual clones.
## Version History
- v0.1 - Initial release with basic clone functionality
- Added dry-run mode for validation
- Improved error handling and database selection logic