172 lines
4.5 KiB
Markdown
172 lines
4.5 KiB
Markdown
# Rubrik Oracle Backup Scripts for HP-UX
|
|
|
|
This collection of Korn shell (ksh) scripts provides automated backup solutions for Oracle databases using Rubrik Managed Volumes (MVs) on HP-UX systems. The scripts are designed to be HP-UX compatible and handle RMAN backups with incremental merge functionality.
|
|
|
|
## Prerequisites
|
|
|
|
- **Operating System**: HP-UX 11i or later (also works on Linux/Solaris/AIX)
|
|
- **Shell**: Korn shell (ksh) - standard on HP-UX
|
|
- **Tools**: curl, awk, egrep, date, expr, mkdir, hostname, ps, find, chmod
|
|
- **Oracle**: Oracle Database with RMAN configured
|
|
- **Rubrik**: Access to Rubrik CDM with Managed Volumes configured
|
|
- **Permissions**: Scripts should be run as the Oracle user
|
|
|
|
## RMAN Configuration
|
|
|
|
The script will
|
|
|
|
## Configuration
|
|
|
|
1. Copy `rbk_api.conf.example` to `rbk_api.conf`
|
|
2. Edit `rbk_api.conf` with your Rubrik settings:
|
|
|
|
```bash
|
|
# Rubrik API Configuration
|
|
ID="your-service-account-id"
|
|
SECRET="your-service-account-secret"
|
|
RUBRIK_IP="your-rubrik-cluster-ip"
|
|
|
|
# Mount point prefix for Managed Volumes
|
|
MOUNTPOINT_PREFIX="/rubrik_"
|
|
|
|
# Log retention settings
|
|
HOSTLOGRET=2
|
|
MV_SPACE_WARN=75
|
|
|
|
# Number of RMAN channels to allocate per NFS mount
|
|
RMAN_CHANNELS_PER_MOUNT=1
|
|
|
|
# Logging directories
|
|
API_LOG_DIR=/tmp/rubrik
|
|
RMAN_LOG_DIR=/tmp/rubrik/rman
|
|
|
|
# Alert settings
|
|
ALERT_EMAILS="admin@example.com"
|
|
EMAIL_SUCCESS=1
|
|
```
|
|
|
|
## Scripts Overview
|
|
|
|
### oracle_funcs.ksh
|
|
Shared functions library containing:
|
|
- API authentication and REST calls
|
|
- Managed Volume operations (open/close)
|
|
- Error handling and logging
|
|
- OS detection and date handling
|
|
|
|
### list_mv.ksh
|
|
Lists all Managed Volumes visible to the configured service account, showing each MV's name and `isWritable` status.
|
|
|
|
**Usage:**
|
|
```bash
|
|
./list_mv.ksh
|
|
```
|
|
|
|
**Output:**
|
|
```
|
|
Service account in use is client|...
|
|
Managed Volumes visible to this account:
|
|
mv_name_1: isWritable=true
|
|
mv_name_2: isWritable=false
|
|
```
|
|
|
|
### rubrik_mv_op.ksh
|
|
Opens or closes a Managed Volume for backup operations.
|
|
|
|
**Usage:**
|
|
```bash
|
|
./rubrik_mv_op.ksh -d <DBNAME> -v <logs|data> -o <open|close>
|
|
```
|
|
|
|
**Examples:**
|
|
```bash
|
|
# Open data volume for ORCL database
|
|
./rubrik_mv_op.ksh -d ORCL -v data -o open
|
|
|
|
# Close logs volume for ORCL database
|
|
./rubrik_mv_op.ksh -d ORCL -v logs -o close
|
|
```
|
|
|
|
### rman_db.ksh
|
|
Performs RMAN database backup with incremental merge to Rubrik Managed Volume.
|
|
|
|
**Usage:**
|
|
```bash
|
|
./rman_db.ksh <ORACLE_SID>
|
|
```
|
|
|
|
**Features:**
|
|
- Incremental level 1 backup with merge
|
|
- Automatic MV open/close
|
|
- Configurable RMAN channels per NFS mount (RMAN_CHANNELS_PER_MOUNT)
|
|
- Disk space monitoring
|
|
- Email alerts on failure/success
|
|
- Archive log backup
|
|
|
|
### rman_logs.ksh
|
|
Performs RMAN archive log backup to Rubrik Managed Volume.
|
|
|
|
**Usage:**
|
|
```bash
|
|
./rman_logs.ksh <ORACLE_SID>
|
|
```
|
|
|
|
**Features:**
|
|
- Backs up all not-backed-up archive logs
|
|
- Configurable RMAN channels per NFS mount (RMAN_CHANNELS_PER_MOUNT)
|
|
- Automatic MV open/close
|
|
- Disk space monitoring
|
|
- Optional host-side log purging
|
|
- Email alerts
|
|
|
|
## HP-UX Compatibility Notes
|
|
|
|
These scripts are specifically designed for HP-UX compatibility:
|
|
|
|
- Uses `ksh` instead of `bash`
|
|
- Avoids GNU-specific commands (`grep -o`, `readlink`)
|
|
- Portable `awk` for JSON parsing
|
|
- HP-UX date handling with fallback to GNU date
|
|
- No reliance on symlinks for script location detection
|
|
|
|
## Logging
|
|
|
|
- API calls are logged to `$API_LOG_DIR/api_calls.log`
|
|
- RMAN operations are logged to `$RMAN_LOG_DIR/$ORACLE_SID/`
|
|
- Use `tail -f` on log files for monitoring
|
|
|
|
## Troubleshooting
|
|
|
|
### Common Issues
|
|
|
|
1. **"readlink not found"**: Scripts use portable directory detection
|
|
2. **JSON parsing errors**: Ensure Rubrik API returns expected format
|
|
3. **MV not found**: Check MV naming convention: `${HOST}_${ORACLE_SID}_data/logs`
|
|
4. **Permission denied**: Run as Oracle user, ensure MV mount points are accessible
|
|
5. **Curl errors**: Check network connectivity to Rubrik cluster
|
|
|
|
### Debug Mode
|
|
|
|
Add debug output by modifying scripts to show raw API responses.
|
|
|
|
### Testing Compatibility
|
|
|
|
Run the included `test.ksh` script to verify HP-UX compatibility of required tools.
|
|
|
|
## Security Notes
|
|
|
|
- Store `rbk_api.conf` securely with appropriate permissions
|
|
- Service account should have minimal required permissions
|
|
- Avoid logging secrets in log files
|
|
|
|
## Support
|
|
|
|
For issues specific to Rubrik CDM or Oracle integration, consult:
|
|
- Rubrik documentation
|
|
- Oracle RMAN documentation
|
|
- HP-UX system administration guides
|
|
|
|
## Version History
|
|
|
|
- v1.1: Enhanced list_mv.ksh with isWritable status, HP-UX compatibility improvements
|
|
- v1.0: Initial release with basic RMAN backup functionality |