As released to customer
This commit is contained in:
@@ -1,6 +1,19 @@
|
|||||||
# Python Oracle Scripts for Rubrik Security Cloud
|
# Python Oracle Scripts for Rubrik Security Cloud
|
||||||
|
|
||||||
This directory contains Python scripts that replicate the functionality of the shell scripts for managing Oracle databases in Rubrik Security Cloud (RSC).
|
This directory contains Python command-line tools for Oracle database operations in Rubrik Security Cloud (RSC), including database discovery, snapshot visibility, clone/live mount operations, files-only mounts, and live mount cleanup.
|
||||||
|
|
||||||
|
## RSC Service Account
|
||||||
|
|
||||||
|
A Service Account will need to be created in RSC, and a role assigned to it that allows databases to be listed and mounted.
|
||||||
|
|
||||||
|
The recommended minimum privileges for the role are:
|
||||||
|
|
||||||
|
On the Database Host object level:
|
||||||
|
|
||||||
|
* View Protectable Objects
|
||||||
|
* Mount Snapshot
|
||||||
|
|
||||||
|
Recovery Targets: Same Oracle host
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
@@ -25,81 +38,78 @@ This directory contains Python scripts that replicate the functionality of the s
|
|||||||
|
|
||||||
### clone_oracle_database.py
|
### clone_oracle_database.py
|
||||||
|
|
||||||
Clones an Oracle database to a target host using Rubrik Security Cloud. This replicates the functionality of `rsc_clone.sh`.
|
Creates either a full clone or a live mount of an Oracle database.
|
||||||
|
|
||||||
**Usage:**
|
**Usage:**
|
||||||
```bash
|
```bash
|
||||||
python clone_oracle_database.py -n <newname> -o <optionsfile> --targethost <targethost> [options] <srcdb>
|
./clone_oracle_database.py -n <newname> -o <optionsfile> --targethost <targethost> [options] <srcdb>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Required Arguments:**
|
**Required Arguments:**
|
||||||
- `-n, --newname`: Database name/SID of the new cloned or live mounted database
|
- `-n, --newname`: Database name/SID of the new cloned or live mounted database
|
||||||
- `-o, --optionsfile`: Path to options file containing Oracle parameters
|
- `-o, --optionsfile`: Path to options file containing Oracle parameters
|
||||||
- `--targethost`: Target host where the database will be created
|
- `--targethost`: Target host where the database will be created
|
||||||
- `<srcdb>`: Source database name or RSC database ID
|
- `srcdb`: Source database name or RSC database ID
|
||||||
|
|
||||||
**Optional Arguments:**
|
**Optional Arguments:**
|
||||||
- `-s, --sourcehost`: Source host (when there are multiple databases with the same name)
|
- `-s, --sourcehost`: Source host when multiple databases share the same name
|
||||||
- `-t, --timestamp`: Recovery point timestamp in format "YYYY-MM-DD HH:MM:SS"
|
- `-t, --timestamp`: Recovery point timestamp in format "YYYY-MM-DD HH:MM:SS"
|
||||||
- `-d, --dryrun`: Show configuration without executing the operation
|
- `-d, --dryrun`: Show configuration without executing
|
||||||
- `--livemount`: Create a live mount instead of a clone
|
- `--livemount`: Create a live mount instead of a clone
|
||||||
- `-c, --channels`: Number of RMAN channels for the operation
|
- `-c, --channels`: RMAN channel count (must be positive)
|
||||||
- `-p, --pfile`: Custom pfile path (must be absolute path)
|
- `-p, --pfile`: Absolute path to custom pfile
|
||||||
|
|
||||||
**Examples:**
|
**Examples:**
|
||||||
```bash
|
```bash
|
||||||
# Basic clone with latest PIT
|
# Basic clone
|
||||||
python clone_oracle_database.py -n NEWDB -o options.txt --targethost target-host SHED
|
./clone_oracle_database.py -n NEWDB -o options.txt --targethost target-host SHED
|
||||||
|
|
||||||
# Live mount instead of clone
|
# Live mount
|
||||||
python clone_oracle_database.py -n LIVEMOUNT -o options.txt --targethost target-host --livemount SHED
|
./clone_oracle_database.py -n LIVEMOUNT -o options.txt --targethost target-host --livemount SHED
|
||||||
|
|
||||||
# Clone with specific timestamp
|
# Dry run
|
||||||
python clone_oracle_database.py -n NEWDB -o options.txt --targethost target-host -t "2025-11-14 15:30:00" SHED
|
./clone_oracle_database.py -n NEWDB -o options.txt --targethost target-host --dryrun SHED
|
||||||
|
|
||||||
# Clone with source host disambiguation
|
|
||||||
python clone_oracle_database.py -n NEWDB -o options.txt --targethost target-host -s source-host SHED
|
|
||||||
|
|
||||||
# Dry run to see configuration
|
|
||||||
python clone_oracle_database.py -n NEWDB -o options.txt --targethost target-host --dryrun SHED
|
|
||||||
|
|
||||||
# Clone with custom RMAN channels
|
|
||||||
python clone_oracle_database.py -n NEWDB -o options.txt --targethost target-host -c 4 SHED
|
|
||||||
```
|
|
||||||
|
|
||||||
**Options File Format:**
|
|
||||||
The options file contains Oracle initialization parameters. Example:
|
|
||||||
```
|
|
||||||
CONTROL_FILES='/u01/app/oracle/oradata/NEWDB/control01.ctl, /u01/app/oracle/fast_recovery_area/NEWDB/control02.ctl'
|
|
||||||
DB_FILE_NAME_CONVERT='SHED','NEWDB'
|
|
||||||
DB_CREATE_FILE_DEST=/u01/app/oracle/oradata/NEWDB/
|
|
||||||
AUDIT_FILE_DEST='/u01/app/oracle/admin/NEWDB/adump'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Features:**
|
**Features:**
|
||||||
- **Clone or Live Mount**: Choose between creating a persistent clone or temporary live mount
|
- Supports both clone and live mount flows
|
||||||
- Automatic latest Point-in-Time (PIT) detection when no timestamp specified
|
- Resolves source/target objects through GraphQL
|
||||||
- Host ID resolution for target hosts
|
- Uses latest PIT automatically when timestamp is not provided
|
||||||
- Comprehensive error handling and validation
|
- Includes dry-run output and job status monitoring
|
||||||
- Job status monitoring with progress updates
|
|
||||||
- Dry-run mode for testing configurations
|
|
||||||
|
|
||||||
### list_db_snapshots.py
|
### list_oracle_databases.py
|
||||||
|
|
||||||
|
Lists all Oracle databases protected by Rubrik Security Cloud.
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
```bash
|
||||||
|
./list_oracle_databases.py
|
||||||
|
```
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Displays database name, RSC ID, cluster, host, and relic status
|
||||||
|
- Filters out replicated databases (shows only source databases)
|
||||||
|
- Outputs in a formatted table
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### list_oracle_snapshots.py
|
||||||
|
|
||||||
Lists snapshots and recovery ranges available for a specific Oracle database, including distribution across source, replicated, and archived locations.
|
Lists snapshots and recovery ranges available for a specific Oracle database, including distribution across source, replicated, and archived locations.
|
||||||
|
|
||||||
Usage:
|
**Usage:**
|
||||||
```bash
|
```bash
|
||||||
python list_db_snapshots.py <database_name_or_id>
|
./list_oracle_snapshots.py [database_name_or_id]
|
||||||
```
|
```
|
||||||
|
|
||||||
Examples:
|
**Examples:**
|
||||||
```bash
|
```bash
|
||||||
python list_db_snapshots.py SHED
|
./list_oracle_snapshots.py SHED
|
||||||
python list_db_snapshots.py b4194205-b7d6-5f0b-8360-e6f349b9fd82
|
./list_oracle_snapshots.py b4194205-b7d6-5f0b-8360-e6f349b9fd82
|
||||||
|
./list_oracle_snapshots.py
|
||||||
```
|
```
|
||||||
|
|
||||||
This script will display:
|
**Features:**
|
||||||
- Database information (name, ID, cluster, host)
|
- Database information (name, ID, cluster, host)
|
||||||
- Recoverable ranges (time periods when the database can be recovered)
|
- Recoverable ranges (time periods when the database can be recovered)
|
||||||
- **Snapshot Distribution**: Shows where backups are stored:
|
- **Snapshot Distribution**: Shows where backups are stored:
|
||||||
@@ -109,27 +119,131 @@ This script will display:
|
|||||||
- Missed recoverable ranges (gaps in coverage)
|
- Missed recoverable ranges (gaps in coverage)
|
||||||
|
|
||||||
**Note:** If multiple databases have the same name, the script will list them and ask you to specify the database ID instead.
|
**Note:** If multiple databases have the same name, the script will list them and ask you to specify the database ID instead.
|
||||||
|
If no database argument is provided, the script uses the local database ID.
|
||||||
|
|
||||||
|
### mount_oracle_filesonly.py
|
||||||
|
|
||||||
|
Mounts Oracle database files to a target host without starting the database instance (files-only mount).
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
```bash
|
||||||
|
./mount_oracle_filesonly.py --mountpath <path> [options] [srcdb]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Required Arguments:**
|
||||||
|
- `--mountpath`: Target mount path for the database files
|
||||||
|
|
||||||
|
**Optional Arguments:**
|
||||||
|
- `--targethost`: Target host where files will be mounted (defaults to local hostname)
|
||||||
|
- `--timestamp`: Recovery point timestamp in format "YYYY-MM-DD HH:MM:SS"
|
||||||
|
- `srcdb`: Source database name or RSC database ID (defaults to local database)
|
||||||
|
|
||||||
|
**Examples:**
|
||||||
|
```bash
|
||||||
|
# Mount local database files to /tmp/mount
|
||||||
|
./mount_oracle_filesonly.py --mountpath /tmp/mount
|
||||||
|
|
||||||
|
# Mount specific database to remote host
|
||||||
|
./mount_oracle_filesonly.py --targethost target-host --mountpath /tmp/mount SHED
|
||||||
|
|
||||||
|
# Mount with specific timestamp
|
||||||
|
./mount_oracle_filesonly.py --mountpath /tmp/mount --timestamp "2025-11-25 12:00:00" SHED
|
||||||
|
```
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Mounts database files without starting the Oracle instance
|
||||||
|
- Useful for file-level restores or manual recovery operations
|
||||||
|
- Automatic latest Point-in-Time detection when no timestamp specified
|
||||||
|
- Defaults to local hostname and local database when not specified
|
||||||
|
|
||||||
|
### list_oracle_mounts.py
|
||||||
|
|
||||||
|
Lists all Oracle Live Mounts in Rubrik Security Cloud with filtering and sorting options.
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
```bash
|
||||||
|
./list_oracle_mounts.py [options]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Options:**
|
||||||
|
- `--name`: Filter by mounted database name
|
||||||
|
- `--cluster-uuid`: Filter by cluster UUID
|
||||||
|
- `--source-db-id`: Filter by source database ID
|
||||||
|
- `--org-id`: Filter by organization ID
|
||||||
|
- `--sort-field`: Sort by NAME, CREATION_DATE, or STATUS
|
||||||
|
- `--sort-order`: Sort order (ASC or DESC, default: ASC)
|
||||||
|
- `--limit`: Maximum number of results (default: 50)
|
||||||
|
|
||||||
|
**Examples:**
|
||||||
|
```bash
|
||||||
|
# List all live mounts
|
||||||
|
./list_oracle_mounts.py
|
||||||
|
|
||||||
|
# List mounts for a specific source database
|
||||||
|
./list_oracle_mounts.py --source-db-id abc123-def456
|
||||||
|
|
||||||
|
# List mounts sorted by creation date
|
||||||
|
./list_oracle_mounts.py --sort-field CREATION_DATE --sort-order DESC
|
||||||
|
```
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Displays mount ID, source DB, mounted DB name, cluster, target host, status, and creation date
|
||||||
|
- Automatically defaults to local database if no filters specified
|
||||||
|
- Outputs in a formatted table
|
||||||
|
|
||||||
|
### unmount_oracle_livemount.py
|
||||||
|
|
||||||
|
Unmounts an Oracle Live Mount using its RSC ID.
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
```bash
|
||||||
|
./unmount_oracle_livemount.py <livemount_id> [--force]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Required Arguments:**
|
||||||
|
- `livemount_id`: RSC ID of the Oracle Live Mount to unmount (get from list_oracle_mounts.py)
|
||||||
|
|
||||||
|
**Optional Arguments:**
|
||||||
|
- `--force`: Force unmount even if the mount is in use
|
||||||
|
|
||||||
|
**Examples:**
|
||||||
|
```bash
|
||||||
|
# Normal unmount
|
||||||
|
./unmount_oracle_livemount.py abc123-def456-ghi789
|
||||||
|
|
||||||
|
# Force unmount
|
||||||
|
./unmount_oracle_livemount.py abc123-def456-ghi789 --force
|
||||||
|
```
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Clean unmount of live mounts
|
||||||
|
- Force option for emergencies
|
||||||
|
- Displays result links and status
|
||||||
|
|
||||||
### introspect_schema.py
|
### introspect_schema.py
|
||||||
|
|
||||||
Explores the GraphQL schema dynamically using GraphQL introspection.
|
Inspects GraphQL schema types exposed by RSC.
|
||||||
|
|
||||||
Usage:
|
**Usage:**
|
||||||
```bash
|
```bash
|
||||||
# Explore Oracle-related types
|
# List Oracle-related types
|
||||||
python introspect_schema.py
|
./introspect_schema.py
|
||||||
|
|
||||||
# Get detailed info about a specific type
|
# Dump schema details for one type
|
||||||
python introspect_schema.py OracleDatabase
|
./introspect_schema.py OracleDatabase
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Lists Oracle-related GraphQL types
|
||||||
|
- Retrieves detailed introspection output for a requested type
|
||||||
|
- Useful for query/mutation development and troubleshooting
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
- `rsc_auth.py`: Handles authentication with RSC using OAuth2 client credentials
|
- `rsc.py`: Contains RSCAuth class for OAuth2 authentication and RSCGraphQL class for making GraphQL queries to RSC
|
||||||
- `rsc_graphql.py`: Provides a client for making GraphQL queries to RSC, including schema introspection capabilities
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- Tokens are cached securely in `~/.rbkRscsession.*` files
|
- Tokens are cached securely in `~/.rbkRscsession.*` files
|
||||||
- The scripts use the same GraphQL queries as the shell scripts
|
- Scripts use GraphQL queries and mutations against the RSC API
|
||||||
- Error handling includes GraphQL error checking
|
- Error handling includes GraphQL error checking
|
||||||
@@ -371,7 +371,7 @@ Examples:
|
|||||||
print(f"INFO: Mount job started with ID: {job_id}")
|
print(f"INFO: Mount job started with ID: {job_id}")
|
||||||
|
|
||||||
# Monitor the job
|
# Monitor the job
|
||||||
monitor_job_status(job_id, db['cluster']['id'])
|
# monitor_job_status(job_id, db['cluster']['id'])
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ERROR: {e}", file=sys.stderr)
|
print(f"ERROR: {e}", file=sys.stderr)
|
||||||
|
|||||||
Reference in New Issue
Block a user