RMAN Script Templates¶
Purpose: RMAN (Recovery Manager) script templates for common backup and recovery operations in OraDBA.
Audience: DBAs implementing backup strategies.
Introduction¶
OraDBA includes RMAN (Recovery Manager) script templates for common backup and recovery operations. These templates provide a starting point for database backup strategies and work with the Plugin System to support different Oracle product types.
RMAN Wrapper Script¶
oradba_rman.sh¶
OraDBA provides a shell wrapper for executing RMAN scripts with enhanced features:
# Execute RMAN script for a single database
oradba_rman.sh --sid FREE --rcv backup_full.rcv
# Execute for multiple databases in parallel
oradba_rman.sh --sid "CDB1,CDB2,CDB3" --rcv backup_full.rcv --parallel 2
# Override default settings
oradba_rman.sh --sid FREE --rcv backup_full.rcv \
--channels 4 \
--compression HIGH \
--format "/backup/%d_%T_%U.bkp" \
--tag MONTHLY_BACKUP \
--notify dba@example.com
Features:
- Template Processing: Dynamic substitution of
<ALLOCATE_CHANNELS>,<RELEASE_CHANNELS>,<FORMAT>,<TAG>,<COMPRESSION>,<BACKUP_PATH>,<ORACLE_SID>,<START_DATE>tags - Error Detection: Checks for RMAN-00569 error pattern to catch failures (RMAN returns exit code 0 even on errors)
- Parallel Execution: Run RMAN for multiple SIDs concurrently (background jobs or GNU parallel)
- Dual Logging: Generic logs in
$ORADBA_LOG+ SID-specific logs in$ORADBA_ORA_ADMIN_SID/log - Script Preservation: Automatically saves processed .rcv scripts to log directory for troubleshooting
- Enhanced Dry-Run: Saves and displays generated scripts, shows exact RMAN command
- Cleanup Control: Optional
--no-cleanupflag preserves temp files for debugging - Email Notifications: Send alerts on success/failure via mail or sendmail
- Configuration: SID-specific settings via
$ORADBA_ORA_ADMIN_SID/etc/oradba_rman.conf
Usage:
oradba_rman.sh --sid <SID> --rcv <script.rcv> [OPTIONS]
Required Arguments:
--sid SID[,SID,...] Oracle SID(s), comma-separated for multiple
--rcv SCRIPT RMAN script file (.rcv extension)
Optional Arguments:
--channels N Number of parallel channels (default: from config)
--format FORMAT Backup format string (default: from config)
--tag TAG Backup tag (default: from config)
--compression LEVEL NONE|LOW|BASIC|MEDIUM|HIGH (default: BASIC)
Note: BASIC requires no license, MEDIUM/HIGH require
Oracle Advanced Compression option
--backup-path PATH Backup destination path (default: from config)
--tablespaces NAMES Tablespace names, comma-separated (e.g., USERS,TOOLS)
--datafiles NUMBERS Datafile numbers or paths, comma-separated (e.g., 1,2,3)
--pdb NAMES Pluggable database names, comma-separated (e.g., PDB1,PDB2)
--catalog CONNECT RMAN catalog connection string
--notify EMAIL Send notifications to email address
--parallel N Max parallel SID executions (default: 1)
--dry-run Show generated script and command without executing
--no-cleanup Keep temporary files after execution (for debugging)
--verbose Enable verbose output
--help Show detailed help
Configuration:
Create SID-specific configuration in $ORADBA_ORA_ADMIN_SID/etc/oradba_rman.conf:
# Copy example configuration
cp $ORADBA_PREFIX/templates/etc/oradba_rman.conf.example \
$ORADBA_ORA_ADMIN_SID/etc/oradba_rman.conf
# Edit configuration
export RMAN_CHANNELS=2
export RMAN_BACKUP_PATH="/backup/prod" # If empty, uses Fast Recovery Area
export RMAN_FORMAT="%d_%T_%U.bkp" # Filename pattern only (no path)
export RMAN_TAG="AUTO_BACKUP"
export RMAN_COMPRESSION="BASIC"
export RMAN_CATALOG=""
export RMAN_TABLESPACES="" # e.g., "USERS,TOOLS,DATA"
export RMAN_DATAFILES="" # e.g., "1,2,3" or "/path/file1.dbf,/path/file2.dbf"
export RMAN_PLUGGABLE_DATABASE="" # e.g., "PDB1,PDB2,PDB3"
export RMAN_NOTIFY_EMAIL="dba@example.com"
export RMAN_NOTIFY_ON_SUCCESS=false
export RMAN_NOTIFY_ON_ERROR=true
Important Configuration Notes:
RMAN_COMPRESSION: Compression levels and licensing:BASIC(default): No additional license requiredLOW: No additional license required (less compression than BASIC)MEDIUM,HIGH: Require Oracle Advanced Compression option license-
NONE: No compression (fastest, largest backup size) -
RMAN_FORMAT: Contains only the filename pattern (e.g.,%d_%T_%U.bkp) - Do NOT include the path in this variable
-
Variables:
%d(database name),%T(timestamp),%U(unique identifier) -
RMAN_BACKUP_PATH: Contains only the directory path (e.g.,/backup/prod) - If empty or not set:
- RMAN backups use the Fast Recovery Area (FRA)
- SQL-generated files (pfile, controlfile traces) use
${ORADBA_ORA_ADMIN_SID}/backup/
- The wrapper automatically combines path + format:
FORMAT '/backup/prod/DB_20260106_ABC.bkp' - Trailing slash is handled automatically
- Backup directory is created automatically if it doesn't exist
Template Tags:
RMAN scripts use template tags that are replaced at runtime:
Basic Template Tags:
<ALLOCATE_CHANNELS>: GeneratesALLOCATE CHANNELcommands based on--channels<RELEASE_CHANNELS>: GeneratesRELEASE CHANNELcommands matching allocated channels<FORMAT>: Substituted withFORMATclause from--format<TAG>: Substituted withTAGclause from--tag<COMPRESSION>: Substituted with compression clause from--compression<BACKUP_PATH>: Substituted with backup path (includes trailing slash for easy path construction)<ORACLE_SID>: Substituted with current Oracle SID<START_DATE>: Substituted with timestamp in YYYYMMDD_HHMMSS format
Advanced Template Tags (v0.14.0+):
<SET_COMMANDS>: Custom RMAN SET commands (inline or external file)<TABLESPACES>: Specific tablespaces for selective backup<DATAFILES>: Specific datafiles for selective backup<PLUGGABLE_DATABASE>: Specific PDBs for container database backups<SECTION_SIZE>: Enables multisection backup for large datafiles<ARCHIVE_RANGE>: Archive log range specification (ALL, FROM TIME, FROM SCN, etc.)<ARCHIVE_PATTERN>: LIKE clause for archive log filtering<RESYNC_CATALOG>: RMAN catalog resync command (when catalog configured)<SPFILE_BACKUP>: Conditional SPFILE text backup (pfile creation from spfile)<BACKUP_KEEP_TIME>: Long-term retention with KEEP UNTIL TIME clause<RESTORE_POINT>: Guaranteed restore point creation for long-term recovery<CUSTOM_PARAM_1>,<CUSTOM_PARAM_2>,<CUSTOM_PARAM_3>: User-defined parameters
Advanced Configuration:
For advanced RMAN features, configure additional parameters in $ORADBA_ORA_ADMIN_SID/etc/oradba_rman.conf:
# -----------------------------------------------------------------------
# RMAN Global SET Commands (Option 3: Hybrid approach)
# -----------------------------------------------------------------------
# Inline SET commands (simple, single or few commands)
export RMAN_SET_COMMANDS_INLINE="CONFIGURE CONTROLFILE AUTOBACKUP ON;"
# OR external SET commands file (complex, many commands)
export RMAN_SET_COMMANDS_FILE="${ORADBA_ORA_ADMIN_SID}/etc/rman_set_commands.rcv"
# -----------------------------------------------------------------------
# Backup Scope Configuration (Selective Backups)
# -----------------------------------------------------------------------
# Specific tablespaces (comma-separated, empty = full database)
export RMAN_TABLESPACES=""
# Example: export RMAN_TABLESPACES="USERS,TOOLS,APP_DATA"
# Specific datafiles (comma-separated numbers or paths, empty = all datafiles)
export RMAN_DATAFILES=""
# Example: export RMAN_DATAFILES="4,5,6"
# Example: export RMAN_DATAFILES="'/u01/oradata/FREE/users01.dbf','/u01/oradata/FREE/users02.dbf'"
# Specific PDBs (comma-separated, empty = CDB only or all PDBs)
export RMAN_PLUGGABLE_DATABASE=""
# Example: export RMAN_PLUGGABLE_DATABASE="PDB1,PDB2"
# -----------------------------------------------------------------------
# Multisection Backup Configuration (Large Datafile Parallelization)
# -----------------------------------------------------------------------
# Section size for multisection backups (empty = regular backup)
export RMAN_SECTION_SIZE=""
# Example: export RMAN_SECTION_SIZE="10G"
# Example: export RMAN_SECTION_SIZE="32G"
# -----------------------------------------------------------------------
# Archive Log Backup Configuration
# -----------------------------------------------------------------------
# Archive log range (default: ALL)
export RMAN_ARCHIVE_RANGE="ALL"
# Example: export RMAN_ARCHIVE_RANGE="FROM TIME 'SYSDATE-1'"
# Example: export RMAN_ARCHIVE_RANGE="FROM SCN 1234567"
# Example: export RMAN_ARCHIVE_RANGE="UNTIL TIME 'SYSDATE-7'"
# Archive log pattern (LIKE clause, empty = no filtering)
export RMAN_ARCHIVE_PATTERN=""
# Example: export RMAN_ARCHIVE_PATTERN="LIKE '/arch/arch_prod_%'"
# -----------------------------------------------------------------------
# RMAN Catalog Resync
# -----------------------------------------------------------------------
# Explicitly resync catalog after backup (default: true)
export RMAN_RESYNC_CATALOG="true"
# -----------------------------------------------------------------------
# Custom Parameters (User-Defined)
# -----------------------------------------------------------------------
# Three user-defined parameters for custom template extensions
export RMAN_CUSTOM_PARAM_1=""
export RMAN_CUSTOM_PARAM_2=""
export RMAN_CUSTOM_PARAM_3=""
# -----------------------------------------------------------------------
# SPFILE Backup Configuration
# -----------------------------------------------------------------------
# Enable SPFILE text backup (pfile creation from spfile)
# Creates a text pfile after backup for disaster recovery
export RMAN_SPFILE_BACKUP="true"
# -----------------------------------------------------------------------
# Long-Term Retention Configuration
# -----------------------------------------------------------------------
# Backup keep time for guaranteed retention (KEEP UNTIL TIME clause)
# Only used in bck_db_keep.rcv for long-term archival backups
export RMAN_BACKUP_KEEP_TIME=""
# Example: export RMAN_BACKUP_KEEP_TIME="KEEP UNTIL TIME 'SYSDATE+365'"
# Restore point for guaranteed restore capability
# Only used in bck_db_keep.rcv for guaranteed restore points
export RMAN_RESTORE_POINT=""
# Example: export RMAN_RESTORE_POINT="backup_rp_$(date +%Y%m%d)"
Advanced Examples:
# Selective backup of specific tablespaces (using CLI parameter - preferred)
oradba_rman.sh --sid PROD --rcv backup_full.rcv --tablespaces USERS,TOOLS
# Selective backup of specific tablespaces (using config variable)
export RMAN_TABLESPACES="USERS,TOOLS"
oradba_rman.sh --sid PROD --rcv backup_full.rcv
# Selective backup of specific datafiles (using CLI parameter - preferred)
oradba_rman.sh --sid PROD --rcv bck_inc0.rcv --datafiles 4,5,6
# Selective backup of specific datafiles by path (using CLI parameter)
oradba_rman.sh --sid PROD --rcv bck_inc0.rcv \
--datafiles "/u01/oradata/PROD/users01.dbf,/u01/oradata/PROD/users02.dbf"
# Selective backup of specific pluggable databases (using CLI parameter - preferred)
oradba_rman.sh --sid CDB1 --rcv bck_inc0_pdb.rcv --pdb PDB1,PDB2
# Selective backup of specific pluggable databases (using config variable)
export RMAN_PLUGGABLE_DATABASE="PDB1,PDB2"
oradba_rman.sh --sid CDB1 --rcv bck_inc0_pdb.rcv
# Multisection backup for large database (10G sections, 4 channels)
export RMAN_SECTION_SIZE="10G"
oradba_rman.sh --sid BIGDB --rcv backup_full.rcv --channels 4
# Backup only yesterday's archive logs
export RMAN_ARCHIVE_RANGE="FROM TIME 'SYSDATE-1' UNTIL TIME 'SYSDATE'"
oradba_rman.sh --sid PROD --rcv backup_archivelogs.rcv
# PDB-only backup in container database
export RMAN_PLUGGABLE_DATABASE="PDB1,PDB2,PDB3"
oradba_rman.sh --sid CDB1 --rcv backup_full.rcv
# Use external SET commands file
export RMAN_SET_COMMANDS_FILE="${ORADBA_ORA_ADMIN_SID}/etc/rman_set_commands.rcv"
cat > ${ORADBA_ORA_ADMIN_SID}/etc/rman_set_commands.rcv << 'EOF'
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/rman/%F';
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO CATALOG;
EOF
oradba_rman.sh --sid PROD --rcv backup_full.rcv
Examples:
# Single database with defaults from config
oradba_rman.sh --sid FREE --rcv backup_full.rcv
# Multiple databases in parallel
oradba_rman.sh --sid "CDB1,CDB2,CDB3" --rcv backup_full.rcv --parallel 3
# High compression backup with notification
oradba_rman.sh --sid PROD --rcv backup_full.rcv \
--compression HIGH \
--notify dba-team@example.com
# Custom backup destination path
oradba_rman.sh --sid PROD --rcv backup_full.rcv \
--backup-path /backup/prod_daily \
--format "DB_%d_%T_%U.bkp"
# Use Fast Recovery Area (no --backup-path specified)
# RMAN backups → FRA
# SQL files (pfile/traces) → ${ORADBA_ORA_ADMIN_SID}/backup/
oradba_rman.sh --sid PROD --rcv backup_full.rcv \
--format "%d_FULL_%T_%U.bkp"
# Dry run to test template processing (saves and displays script)
oradba_rman.sh --sid FREE --rcv backup_full.rcv --dry-run
# Keep temp files for troubleshooting
oradba_rman.sh --sid FREE --rcv backup_full.rcv --no-cleanup
# Custom format and tag
oradba_rman.sh --sid FREE --rcv backup_full.rcv \
--backup-path /backup/monthly \
--format "MONTHLY_%d_%T_%U.bkp" \
--tag MONTHLY_FULL_20260102
Troubleshooting:
When RMAN execution fails, the wrapper automatically saves the processed script for analysis:
# Check RMAN log
cat /u01/admin/FREE/log/backup_full_20260105_143022.log
# Examine processed RMAN script (template tags resolved)
cat /u01/admin/FREE/log/backup_full_20260105_143022.rcv
# Keep temp directory for debugging
oradba_rman.sh --sid FREE --rcv backup_full.rcv --no-cleanup
# Temp files preserved in: /tmp/oradba_rman_20260105_143022/
Location¶
# RMAN scripts location
echo $ORADBA_PREFIX/rcv
# Output: /opt/oradba/rcv
# Navigate to RMAN directory
cd $ORADBA_PREFIX/rcv
# Or use alias
cdr
Available Scripts¶
OraDBA includes 24 RMAN script templates covering various backup scenarios, maintenance operations, and reporting tasks. All scripts are converted from TVD Backup templates and adapted for OraDBA's template tag system.
Backup Scripts¶
Full and Incremental Backups¶
| Script | Description | Use Case |
|---|---|---|
backup_full.rcv |
Full database backup with maintenance | Production full backups |
bck_db_keep.rcv |
Full backup with retention guarantee | Long-term archive backups |
bck_db_validate.rcv |
Full database validation | Verify backup integrity |
bck_inc0.rcv |
Incremental level 0 with archive logs | Weekly baseline backup |
bck_inc0_noarc.rcv |
Incremental level 0 without archive logs | Baseline without archive cleanup |
bck_inc0_cold.rcv |
Offline (cold) incremental level 0 | Scheduled maintenance window |
bck_inc0_df.rcv |
Incremental level 0 for specific datafiles | Selective datafile backup |
bck_inc0_pdb.rcv |
Incremental level 0 for pluggable databases | PDB-specific backups in CDB |
bck_inc0_rec_area.rcv |
Incremental level 0 to recovery area | Backup to FRA |
bck_inc0_ts.rcv |
Incremental level 0 for specific tablespaces | Selective tablespace backup |
bck_inc1c.rcv |
Incremental level 1 cumulative with archives | Daily cumulative backup |
bck_inc1c_noarc.rcv |
Incremental level 1 cumulative without archives | Cumulative without archive logs |
bck_inc1d.rcv |
Incremental level 1 differential with archives | Daily differential backup |
bck_inc1d_noarc.rcv |
Incremental level 1 differential without archives | Differential without archive logs |
Specialized Backups¶
| Script | Description | Use Case |
|---|---|---|
bck_recovery_area.rcv |
Fast recovery area backup (requires SBT) | Backup FRA to tape |
bck_standby_inc0.rcv |
Incremental level 0 for standby setup | Data Guard initialization |
Maintenance Scripts¶
| Script | Description | Use Case |
|---|---|---|
mnt_chk.rcv |
Crosscheck backups/copies, delete expired | Regular maintenance |
mnt_chk_arc.rcv |
Crosscheck archive logs | Archive log validation |
mnt_del_arc.rcv |
Delete archive logs (commented for safety) | Data Guard housekeeping |
mnt_del_obs.rcv |
Delete obsolete backups (commented) | Backup cleanup |
mnt_del_obs_nomaint.rcv |
Delete obsolete without maintenance window | Continuous operation cleanup |
mnt_reg.rcv |
Register database, set snapshot controlfile | Catalog registration |
mnt_sync.rcv |
Resync RMAN catalog | Catalog synchronization |
Reporting Scripts¶
| Script | Description | Use Case |
|---|---|---|
rpt_bck.rcv |
Report backup status and requirements | Backup status reports |
Script Details¶
backup_full.rcv¶
Comprehensive full database backup with maintenance operations:
# Using wrapper script (recommended)
oradba_rman.sh --sid FREE --rcv backup_full.rcv
# Direct execution with RMAN (static values)
rman target / @$ORADBA_PREFIX/rcv/backup_full.rcv
What it does:
- Full database backup with all datafiles
- Archive log backup
- Control file and SPFILE backup
- Automatic backup validation
- DELETE OBSOLETE and CROSSCHECK operations
- Catalog resync (if configured)
- Backup status reporting
bck_inc0.rcv / bck_inc1d.rcv / bck_inc1c.rcv¶
Standard incremental backup templates following Oracle best practices:
# Weekly level 0 backup
oradba_rman.sh --sid PROD --rcv bck_inc0.rcv --tag WEEKLY_L0
# Daily differential incremental (smaller, faster)
oradba_rman.sh --sid PROD --rcv bck_inc1d.rcv --tag DAILY_DIFF
# Daily cumulative incremental (larger, faster recovery)
oradba_rman.sh --sid PROD --rcv bck_inc1c.rcv --tag DAILY_CUMUL
Incremental Strategy:
- Level 0: Full backup used as baseline for incrementals
- Level 1 Differential: Backs up blocks changed since last level 0 or 1
- Level 1 Cumulative: Backs up all blocks changed since last level 0
bck_inc0_pdb.rcv / bck_inc0_ts.rcv / bck_inc0_df.rcv¶
Selective backup templates for specific database components:
# Backup specific PDBs in container database
export RMAN_PLUGGABLE_DATABASE="PDB1,PDB2"
oradba_rman.sh --sid CDB1 --rcv bck_inc0_pdb.rcv
# Backup specific tablespaces (using config variable)
export RMAN_TABLESPACES="USERS,TOOLS"
oradba_rman.sh --sid PROD --rcv bck_inc0_ts.rcv
# Backup specific tablespaces (using CLI parameter - preferred)
oradba_rman.sh --sid PROD --rcv bck_inc0_ts.rcv --tablespaces USERS,TOOLS
# Backup specific datafiles (using config variable)
export RMAN_DATAFILES="4,5,6"
oradba_rman.sh --sid PROD --rcv bck_inc0_df.rcv
# Backup specific datafiles (using CLI parameter - preferred)
oradba_rman.sh --sid PROD --rcv bck_inc0_df.rcv --datafiles 4,5,6
Maintenance Scripts Usage¶
# Regular maintenance: crosscheck and delete expired
oradba_rman.sh --sid PROD --rcv mnt_chk.rcv
# Delete obsolete backups (edit file to uncomment delete command)
oradba_rman.sh --sid PROD --rcv mnt_del_obs.rcv
# Sync RMAN catalog
oradba_rman.sh --sid PROD --rcv mnt_sync.rcv --catalog "rman/pass@catdb"
Safety Note: Maintenance scripts that perform deletions (mnt_del_arc.rcv,
mnt_del_obs.rcv) have delete commands commented out by default. Review and
uncomment only after verifying configuration.
Template Tags:
The script uses template tags that are dynamically replaced:
<ALLOCATE_CHANNELS>: Replaced with channel allocation commands<RELEASE_CHANNELS>: Replaced with channel release commands (matches allocated channels)<FORMAT>: Replaced with FORMAT clause<TAG>: Replaced with TAG clause<COMPRESSION>: Replaced with compression clause<BACKUP_PATH>: Replaced with backup path (with trailing slash)<ORACLE_SID>: Replaced with current Oracle SID<START_DATE>: Replaced with timestamp (YYYYMMDD_HHMMSS)
Customization:
Option 1 - Use wrapper script with command-line arguments:
oradba_rman.sh --sid FREE --rcv backup_full.rcv \
--channels 4 --compression HIGH --format "/backup/%d_%T_%U.bkp"
Option 2 - Configure defaults in $ORADBA_ORA_ADMIN_SID/etc/oradba_rman.conf
Option 3 - Copy and edit the .rcv file directly for static values
Using Template Tags in SQL Commands¶
The template tags can be used in SQL commands within RMAN scripts for creating additional backup files with dynamic naming:
RUN {
<ALLOCATE_CHANNELS>
# Backup database
BACKUP <COMPRESSION> DATABASE <FORMAT> <TAG>;
# Create text versions for documentation
sql "create pfile=''<BACKUP_PATH>init_<ORACLE_SID>_<START_DATE>.ora'' from spfile";
sql "alter database backup controlfile to ''<BACKUP_PATH>controlfile_<ORACLE_SID>_<START_DATE>.ctl''";
sql "alter database backup controlfile to trace as ''<BACKUP_PATH>cre_controlfile_<ORACLE_SID>_<START_DATE>.sql''";
<RELEASE_CHANNELS>
}
Example processed output (when --sid FREE --backup-path /backup/prod is used):
sql "create pfile=''/backup/prod/init_FREE_20260106_143022.ora'' from spfile";
sql "alter database backup controlfile to ''/backup/prod/controlfile_FREE_20260106_143022.ctl''";
sql "alter database backup controlfile to trace as ''/backup/prod/cre_controlfile_FREE_20260106_143022.sql''";
Example processed output (when --sid FREE without --backup-path):
sql "create pfile=''/u01/admin/FREE/backup/init_FREE_20260106_143022.ora'' from spfile";
sql "alter database backup controlfile to ''/u01/admin/FREE/backup/controlfile_FREE_20260106_143022.ctl''";
sql "alter database backup controlfile to trace as ''/u01/admin/FREE/backup/cre_controlfile_FREE_20260106_143022.sql''";
Benefits:
- Automatic timestamp in filenames prevents overwrites
- SID-specific naming for multi-database environments
- Flexible path construction with
<BACKUP_PATH>(includes trailing slash) - Consistent naming across all backup artifacts
- When no path specified: RMAN uses FRA, text files go to
${ORADBA_ORA_ADMIN_SID}/backup/
Using RMAN with OraDBA¶
Basic RMAN Usage¶
# Set environment
source oraenv.sh FREE
# Connect to RMAN
rman target /
# Or with command history (rlwrap)
rmanh
# Run script
RMAN> @backup_full.rman
RMAN with Catalog¶
# Configure catalog connection in oradba_customer.conf
export ORADBA_RMAN_CATALOG="catalog rman/password@catdb"
# Connect with catalog
rmanc
# Or with rlwrap
rmanch
Run RMAN Script from Shell¶
# Using wrapper script (recommended)
oradba_rman.sh --sid FREE --rcv backup_full.rcv
# Direct RMAN execution
rman target / @$ORADBA_PREFIX/rcv/backup_full.rcv
# With logging (direct execution)
rman target / @$ORADBA_PREFIX/rcv/backup_full.rcv log=/tmp/backup.log
# Wrapper provides automatic dual logging:
# - $ORADBA_LOG/oradba_rman_TIMESTAMP.log (wrapper log)
# - $ORADBA_ORA_ADMIN_SID/log/backup_full_TIMESTAMP.log (RMAN output)
Creating Custom RMAN Scripts¶
Script Template¶
Static RMAN Script (.rman):
# ------------------------------------------------------------------------------
# Script......: my_backup.rman
# Author......: Your Name
# Date........: YYYY-MM-DD
# Purpose.....: Brief description
# Usage.......: rman target / @my_backup.rman
# ------------------------------------------------------------------------------
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
RUN {
ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;
ALLOCATE CHANNEL ch2 DEVICE TYPE DISK;
BACKUP AS COMPRESSED BACKUPSET
DATABASE
FORMAT '/backup/%d_%T_%U.bkp'
TAG 'FULL_BACKUP';
BACKUP CURRENT CONTROLFILE
FORMAT '/backup/ctrl_%d_%T_%U.ctl';
BACKUP SPFILE
FORMAT '/backup/spfile_%d_%T_%U.ora';
RELEASE CHANNEL ch1;
RELEASE CHANNEL ch2;
}
Template RMAN Script (.rcv) - Recommended:
# ------------------------------------------------------------------------------
# Script......: my_backup.rcv
# Author......: Your Name
# Date........: YYYY-MM-DD
# Purpose.....: Brief description with template support
# Usage.......: oradba_rman.sh --sid DB01 --rcv my_backup.rcv
# ------------------------------------------------------------------------------
SHOW ALL;
RUN {
# Allocate channels dynamically
<ALLOCATE_CHANNELS>
# Full database backup with dynamic settings
BACKUP <COMPRESSION>
DATABASE
<FORMAT>
<TAG>;
# Backup controlfile and SPFILE
BACKUP CURRENT CONTROLFILE <FORMAT> TAG 'CONTROLFILE';
BACKUP SPFILE <FORMAT> TAG 'SPFILE';
# Optional: Create text versions for documentation
sql "create pfile=''<BACKUP_PATH>init_<ORACLE_SID>_<START_DATE>.ora'' from spfile";
sql "alter database backup controlfile to trace as ''<BACKUP_PATH>cre_controlfile_<ORACLE_SID>_<START_DATE>.sql''";
# Release channels dynamically
<RELEASE_CHANNELS>
}
# Maintenance
DELETE NOPROMPT OBSOLETE;
CROSSCHECK BACKUP;
LIST BACKUP SUMMARY;
Best Practices¶
- Always test in development first
- Use meaningful backup tags
- Include control file and SPFILE
- Configure retention policy
- Enable controlfile autobackup
- Use compression for disk backups
- Verify backups after completion
- Document backup strategy
- Test recovery procedures regularly
- Monitor backup job completion
Common RMAN Operations¶
Full Database Backup¶
Incremental Backup¶
Backup Specific Tablespace¶
List Backups¶
Validate Backup¶
Delete Obsolete Backups¶
Backup Strategy Examples¶
Daily Incremental Strategy¶
# Sunday: Level 0 (full)
BACKUP INCREMENTAL LEVEL 0 DATABASE
TAG 'WEEKLY_FULL';
# Monday-Saturday: Level 1
BACKUP INCREMENTAL LEVEL 1 DATABASE
TAG 'DAILY_INCREMENTAL';
Backup with Validation¶
Compressed Backup to Disk¶
Troubleshooting¶
RMAN Script Not Found¶
# Check script location
ls -l $ORADBA_PREFIX/rcv/*.rman
# Use full path
rman target / @/opt/oradba/rcv/backup_full.rman
Backup Fails¶
# Check RMAN configuration
RMAN> SHOW ALL;
# Check backup destination space
RMAN> SHOW PARAMETER DB_RECOVERY_FILE_DEST;
# Verify controlfile autobackup
RMAN> SHOW CONTROLFILE AUTOBACKUP;
Permission Issues¶
# Check backup directory permissions
ls -ld /backup
# Create directory if needed
mkdir -p /backup
chown oracle:oinstall /backup
See Also¶
- SQL Scripts - Database administration scripts
- Functions - Database functions reference
- Configuration - Setting ORADBA_RMAN_CATALOG
- Troubleshooting - RMAN issues
Navigation¶
Previous: SQL Scripts Reference
Next: Database Functions Library