How to Perform Oracle RMAN Backups and Basic Commands

English

In Oracle Database operations, data protection is the top priority. Oracle Recovery Manager (Oracle RMAN) is the standard tool for achieving efficient Oracle backups and rapid recovery. This article provides an easy-to-understand guide for beginner to intermediate Oracle engineers on various backup procedures using RMAN, accompanied by actual execution logs.

Conclusion: The Shortest Procedure for RMAN Backup

The basic flow for taking a full database backup using RMAN is as follows:

  1. Start RMAN: Connect to the target DB using rman target /.
  2. Check Log Mode: Ensure the database is in ARCHIVELOG mode (a prerequisite for production environments).
  3. Execute Command: Run BACKUP DATABASE PLUS ARCHIVELOG;.
  4. Verification: Confirm the backup was successfully generated using LIST BACKUP;.

What is RMAN? Backup Mechanism and Background

RMAN is a dedicated backup tool integrated into Oracle Database. Unlike OS-level copy commands (user-managed backups), it has the following features:

  • Block-level Processing: It only backs up blocks that actually contain data, making it highly efficient.
  • Online Backup: You can obtain consistent backups while the database is running.
  • Automatic Management: It manages backup expiration and handles automatic backups of the control file and server parameter file (SPFILE).

Implementation Steps and Execution Examples

The following examples are based on an Oracle Database 19c environment.

Prerequisites:

  • OS: Oracle Linux 7/8/9
  • Privileges: User with SYSDBA or SYSBACKUP privileges
  • Configuration: Single instance (Root connection assumed for CDB/PDB configurations)
  • DB Mode: ARCHIVELOG mode recommended

Full Database Backup with RMAN

To back up the entire database, use the following commands:

RUN {
  ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;
  BACKUP DATABASE;
  RELEASE CHANNEL ch1;
}
  • ALLOCATE CHANNEL assigns a backup channel.
  • BACKUP DATABASE backs up the entire database.
  • RELEASE CHANNEL releases the channel.
RMAN> RUN {
2>   ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;
3>   BACKUP DATABASE;
4>   RELEASE CHANNEL ch1;
5> }

using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=66 device type=DISK

Starting backup at 25-02-16
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/V19/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/V19/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/V19/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/V19/rctbs01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/V19/users01.dbf
channel ch1: starting piece 1 at 25-02-16
channel ch1: finished piece 1 at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/013huo8s_1_1_1 tag=TAG20250216T151332 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:25
Finished backup at 25-02-16

Starting Control File and SPFILE Autobackup at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-2957249400-20250216-00 comment=NONE
Finished Control File and SPFILE Autobackup at 25-02-16

released channel: ch1

Datafile Backup

To back up a specific datafile, use the following syntax:

BACKUP DATAFILE '/u01/app/oracle/oradata/V19/users01.dbf';
  • Use BACKUP DATAFILE to back up a specific datafile.
RMAN> backup datafile '/u01/app/oracle/oradata/V19/users01.dbf';

Starting backup at 25-02-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=66 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/V19/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-02-16
channel ORA_DISK_1: finished piece 1 at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/033huocb_3_1_1 tag=TAG20250216T151522 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-02-16

Starting Control File and SPFILE Autobackup at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-2957249400-20250216-01 comment=NONE
Finished Control File and SPFILE Autobackup at 25-02-16

Tablespace Backup

To back up a specific tablespace, use the following command:

BACKUP TABLESPACE users;
  • BACKUP TABLESPACE allows you to back up all datafiles belonging to a specified tablespace.
RMAN> BACKUP TABLESPACE users;

Starting backup at 25-02-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/V19/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-02-16
channel ORA_DISK_1: finished piece 1 at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/053huogk_5_1_1 tag=TAG20250216T151740 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-02-16

Starting Control File and SPFILE Autobackup at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-2957249400-20250216-02 comment=NONE
Finished Control File and SPFILE Autobackup at 25-02-16

ARCHIVELOG Backup

In ARCHIVELOG mode, capturing the archived redo logs enables complete recovery.

BACKUP ARCHIVELOG ALL;
RMAN> BACKUP ARCHIVELOG ALL;

Starting backup at 25-02-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=12 RECID=1 STAMP=1193238572
input archived log thread=1 sequence=13 RECID=2 STAMP=1193239122
channel ORA_DISK_1: starting piece 1 at 25-02-16
channel ORA_DISK_1: finished piece 1 at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/073huoii_7_1_1 tag=TAG20250216T151842 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 25-02-16

Starting Control File and SPFILE Autobackup at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-2957249400-20250216-03 comment=NONE
Finished Control File and SPFILE Autobackup at 25-02-16

To back up the database and archived logs together, use the following command:

BACKUP DATABASE PLUS ARCHIVELOG;
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;

Starting backup at 25-02-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=12 RECID=1 STAMP=1193238572
input archived log thread=1 sequence=13 RECID=2 STAMP=1193239122
input archived log thread=1 sequence=14 RECID=3 STAMP=1193239211
channel ORA_DISK_1: starting piece 1 at 25-02-16
channel ORA_DISK_1: finished piece 1 at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/093huolb_9_1_1 tag=TAG20250216T152011 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-02-16

Starting backup at 25-02-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/V19/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/V19/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/V19/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/V19/rctbs01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/V19/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-02-16
channel ORA_DISK_1: finished piece 1 at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/0a3huolc_10_1_1 tag=TAG20250216T152012 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 25-02-16

Starting backup at 25-02-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=15 RECID=4 STAMP=1193239228
channel ORA_DISK_1: starting piece 1 at 25-02-16
channel ORA_DISK_1: finished piece 1 at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/0b3huols_11_1_1 tag=TAG20250216T152028 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-02-16

Starting Control File and SPFILE Autobackup at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-2957249400-20250216-04 comment=NONE
Finished Control File and SPFILE Autobackup at 25-02-16

Incremental Backup

Incremental backups save time and storage by only backing up blocks that have changed.

BACKUP INCREMENTAL LEVEL 1 DATABASE;
  • LEVEL 0: Full backup (base for incremental backups).
  • LEVEL 1: Differential incremental backup.

Backup as Backupset

A backup set is the default Oracle backup format, which stores data in a compressed manner.

BACKUP AS BACKUPSET DATABASE;

When using backup sets:

  • RMAN automatically excludes unused blocks to reduce backup size.
  • Multi-section backups are supported.

Backup as Image Copy

An image copy is a bit-for-bit copy of the datafiles.

BACKUP AS COPY DATABASE;
  • Specifying AS COPY creates physical copies of the datafiles.
  • This is useful for database cloning and other purposes.
RMAN> BACKUP AS COPY DATABASE;

Starting backup at 25-02-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/V19/system01.dbf
output file name=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/data_D-V19_I-2957249400_TS-SYSTEM_FNO-1_0h3huorp tag=TAG20250216T152337 RECID=1 STAMP=1193239424
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/V19/sysaux01.dbf
output file name=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/data_D-V19_I-2957249400_TS-SYSAUX_FNO-3_0i3huos1 tag=TAG20250216T152337 RECID=2 STAMP=1193239428
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/V19/undotbs01.dbf
output file name=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/data_D-V19_I-2957249400_TS-UNDOTBS1_FNO-4_0j3huos8 tag=TAG20250216T152337 RECID=3 STAMP=1193239435
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/V19/rctbs01.dbf
output file name=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/data_D-V19_I-2957249400_TS-RCTBS_FNO-5_0k3huosf tag=TAG20250216T152337 RECID=4 STAMP=1193239441
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=/u01/app/oracle/oradata/V19/users01.dbf
output file name=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/data_D-V19_I-2957249400_TS-USERS_FNO-7_0l3huosi tag=TAG20250216T152337 RECID=5 STAMP=1193239442
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 25-02-16

Starting Control File and SPFILE Autobackup at 25-02-16
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-2957249400-20250216-06 comment=NONE
Finished Control File and SPFILE Autobackup at 25-02-16

Verifying Backup Files

To view a list of obtained backups, use the following command:

LIST BACKUP;
RMAN> list backup;

List of Backup Sets
===================

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
13      189.08M    DISK        00:00:01     25-02-16
        BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: TAG20250216T152204
        Piece Name: /u01/app/oracle/product/19.0.0/dbhome_1/dbs/0d3huoos_13_1_1

  List of Archived Logs in backup set 13
  Thrd Seq     Low SCN    Low Time Next SCN   Next Time
  ---- ------- ---------- -------- ---------- ---------
  1    12      2271248    23-11-28 2319046    25-02-16
  1    13      2319046    25-02-16 2325175    25-02-16
  1    14      2325175    25-02-16 2326536    25-02-16
  1    15      2326536    25-02-16 2326565    25-02-16
  1    16      2326565    25-02-16 2326756    25-02-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
14      Full    2.31G      DISK        00:00:11     25-02-16
        BP Key: 14   Status: AVAILABLE  Compressed: NO  Tag: TAG20250216T152205
        Piece Name: /u01/app/oracle/product/19.0.0/dbhome_1/dbs/0e3huoou_14_1_1
  List of Datafiles in backup set 14
  File LV Type Ckp SCN    Ckp Time Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- -------- ----------- ------ ----
  1       Full 2326770    25-02-16              NO    /u01/app/oracle/oradata/V19/system01.dbf
  3       Full 2326770    25-02-16              NO    /u01/app/oracle/oradata/V19/sysaux01.dbf
  4       Full 2326770    25-02-16              NO    /u01/app/oracle/oradata/V19/undotbs01.dbf
  5       Full 2326770    25-02-16              NO    /u01/app/oracle/oradata/V19/rctbs01.dbf
  7       Full 2326770    25-02-16              NO    /u01/app/oracle/oradata/V19/users01.dbf

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
15      5.00K      DISK        00:00:00     25-02-16
        BP Key: 15   Status: AVAILABLE  Compressed: NO  Tag: TAG20250216T152221
        Piece Name: /u01/app/oracle/product/19.0.0/dbhome_1/dbs/0f3huopd_15_1_1

  List of Archived Logs in backup set 15
  Thrd Seq     Low SCN    Low Time Next SCN   Next Time
  ---- ------- ---------- -------- ---------- ---------
  1    17      2326756    25-02-16 2326781    25-02-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
16      Full    10.20M     DISK        00:00:01     25-02-16
        BP Key: 16   Status: AVAILABLE  Compressed: NO  Tag: TAG20250216T152222
        Piece Name: /u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-2957249400-20250216-05
  SPFILE included: Modification time: 25-02-16
  SPFILE db_unique_name: V19
  Control File included: Ckp SCN: 2326797      Ckp Time: 25-02-16

To verify image copies:

LIST COPY;
RMAN> LIST COPY;

specification does not match any control file copy in repository
specification does not match any archived log in repository
List of Datafile Copies
=======================

Key     File S Completion Time Ckp SCN    Ckp Time Sparse
------- ---- - --------------- ---------- -------- ------
6       1    A 25-02-16        2327048    25-02-16 NO
        Name: /u01/app/oracle/product/19.0.0/dbhome_1/dbs/data_D-V19_I-2957249400_TS-SYSTEM_FNO-1_0n3huov5
             Tag: TAG20250216T152525

7       3    A 25-02-16        2327056    25-02-16 NO
        Name: /u01/app/oracle/product/19.0.0/dbhome_1/dbs/data_D-V19_I-2957249400_TS-SYSAUX_FNO-3_0o3huovc
             Tag: TAG20250216T152525

8       4    A 25-02-16        2327060    25-02-16 NO
        Name: /u01/app/oracle/product/19.0.0/dbhome_1/dbs/data_D-V19_I-2957249400_TS-UNDOTBS1_FNO-4_0p3huovj
             Tag: TAG20250216T152525

9       5    A 25-02-16        2327065    25-02-16 NO
        Name: /u01/app/oracle/product/19.0.0/dbhome_1/dbs/data_D-V19_I-2957249400_TS-RCTBS_FNO-5_0q3huovr
             Tag: TAG20250216T152525

10      7    A 25-02-16        2327068    25-02-16 NO
        Name: /u01/app/oracle/product/19.0.0/dbhome_1/dbs/data_D-V19_I-2957249400_TS-USERS_FNO-7_0r3huovu
             Tag: TAG20250216T152525

Deleting Backups

To delete backups that are no longer needed, use the following command:

DELETE BACKUP;

Management Commands: Verify and Clean Up Backups

Monitor the status of your backups and organize them periodically.

  • Verification (Backup Sets): LIST BACKUP;
  • Verification (Image Copies): LIST COPY;
  • Deletion: DELETE BACKUP; (Physically deletes expired or unnecessary files)

Troubleshooting: Common ORA Errors

Error CodeCauseAction
ORA-19809Fast Recovery Area (FRA) is out of spaceDelete old backups with DELETE OBSOLETE or expand FRA size
ORA-00257Archived log destination is fullBack up and delete archived logs
ORA-19602Backup failed in NOARCHIVELOG modeBack up the DB in MOUNT state or change to ARCHIVELOG mode

Security and Operational Considerations

  • Control File Autobackup: It is strongly recommended to set CONFIGURE CONTROLFILE AUTOBACKUP ON;.
  • Encryption: Consider using SET ENCRYPTION ON; when handling personal information.
  • Recovery Testing: Backups are only useful if they can be restored. Conduct regular recovery drills.

FAQ (Frequently Asked Questions)

Q: Does database performance degrade during backup?

A: RMAN imposes a load during read operations, but you can limit throughput using the RATE parameter.

Q: How do I change the backup file output destination?

A: Use the FORMAT clause, such as BACKUP DATABASE FORMAT '/path/to/backup/%U';.

Q: What is the difference between cumulative and differential incremental backups?

A: Differential (default) backs up changes since the last level 0 or level 1 backup. Cumulative (CUMULATIVE) backs up all changes since the last level 0 backup.


Summary

  • RMAN is the efficient and secure standard Oracle backup tool.
  • DATABASE PLUS ARCHIVELOG ensures data consistency.
  • Utilize incremental backups to save storage and time.
  • Regularly monitor the status with the LIST command.

Note: This article covers Oracle Database 19c (screens and default values may vary in other versions).

[reference]
Oracle Database Backup and Recovery Reference, 19c

コメント

Copied title and URL