RMAN Basics: Connect and Configure
What is RMAN?
RMAN (Recovery Manager) is Oracle's own backup tool. It knows which blocks are used, skips empty ones, checks for corruption and keeps a catalog of every backup so it can restore for you automatically.
Connect
bash
rman target /
# or from another machine
rman target sys@FREE
Where do I connect? For a full backup of a multitenant database, connect to the root (the CDB service). You can then back up the whole CDB or individual PDBs.
Where RMAN Keeps Its Records
| Place | Notes |
|---|---|
| Control file (default) | Simple. Records are kept for control_file_record_keep_time days (default 7). |
| Recovery catalog | A separate database that stores history for many databases for longer |
See and Change Settings
sql
RMAN> SHOW ALL;
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
RMAN> CONFIGURE BACKUP OPTIMIZATION ON;
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
| Setting | What it does |
|---|---|
RETENTION POLICY ... RECOVERY WINDOW OF 7 DAYS | Keep enough backups to restore to any point in the last 7 days |
CONTROLFILE AUTOBACKUP ON | Back up the control file and SPFILE after every backup |
COMPRESSED BACKUPSET | Smaller backups, a little more CPU |
BACKUP OPTIMIZATION ON | Skip files that are already backed up |
ARCHIVELOG DELETION POLICY | Archives are removed only after they are backed up |
The Fast Recovery Area
Set a Fast Recovery Area (FRA) so RMAN has a default home for backups and archives:
sql
ALTER SYSTEM SET db_recovery_file_dest_size = 50G SCOPE = BOTH;
ALTER SYSTEM SET db_recovery_file_dest = '/opt/oracle/fra' SCOPE = BOTH;
Inspect Backups
sql
RMAN> LIST BACKUP SUMMARY;
RMAN> LIST BACKUP OF DATABASE;
RMAN> LIST ARCHIVELOG ALL;
RMAN> REPORT SCHEMA;
RMAN> REPORT NEED BACKUP;
RMAN> REPORT OBSOLETE;
Keep the Catalog Honest
sql
RMAN> CROSSCHECK BACKUP; -- do the files still exist?
RMAN> CROSSCHECK ARCHIVELOG ALL;
RMAN> DELETE EXPIRED BACKUP; -- remove records of missing files
RMAN> DELETE OBSOLETE; -- remove backups outside the retention policy
Tip: Run
DELETE OBSOLETE after every backup job. Otherwise the recovery area slowly fills up.
Run RMAN from a Script
bash
rman target / cmdfile=/home/oracle/scripts/backup.rman log=/home/oracle/logs/backup.log
Conclusion
RMAN is the standard backup tool. Set a retention policy, turn on control file autobackup, use the FRA and keep the catalog clean with CROSSCHECK and DELETE OBSOLETE.
Quick Summary: rman target /, SHOW ALL, CONFIGURE settings, LIST/REPORT to inspect, DELETE OBSOLETE to clean.

