← Back to list

Oracle Database RMAN Backup and Restore

A Practical Step-by-Step Guide for Oracle 19c on Linux

Buddhika Hasitha · 2026-03-20 11:44 · 0 claps · 12.5 min read
#rman #database-backup #backup-and-restore #database-restore #disaster-recovery
Open on Medium ↗
Wiki topics: 🔓 · Open Source

Oracle Database RMAN Backup and Restore

A Practical Step-by-Step Guide for Oracle 19c on Linux

Backing up an Oracle database is only half the job. The real confidence comes when you know that the backup can actually be restored and recovered successfully when needed. In many environments, teams take backups regularly, but a backup is only useful if the restore process has been tested, documented, and understood.

This article walks through a complete Oracle RMAN backup and restore process on Linux. The examples in this guide are written for an Oracle Database 19c environment, but the same overall method can be used for other Oracle versions, such as 12c or 21c, with small adjustments where needed. The base concepts remain the same: prepare the database properly, take a reliable backup, validate it, move it if necessary, restore the control file, mount the database, catalog the backup pieces, restore the datafiles, recover the database, and finally open it.

Although this article provides a practical, step-by-step approach to Oracle database backup and restore, it is always recommended to refer to the official Oracle documentation for accurate guidance, best practices, and production-level implementations.

1. Introduction

Oracle Recovery Manager, commonly known as RMAN, is Oracle’s native backup and recovery utility. It is designed specifically for Oracle databases and understands Oracle file structures such as datafiles, archived redo logs, control files, and server parameter files. Because RMAN is Oracle-aware, it is the preferred and recommended method for performing database backups and restores.

In a real-world environment, a complete backup and restore process generally involves four major stages:

  1. Preparing the database environment for recoverable backups
  2. Taking the backup using RMAN
  3. Validating that the backup is usable
  4. Restoring and recovering the database on the same server or on another server

This article focuses on a practical scenario where a full RMAN backup is taken on one server and then restored to another Linux server.

Although the guide is centered around Oracle 19c, it is important to note that the core backup and recovery principles are version-independent across most modern Oracle releases. File paths, Oracle Home locations, initialization parameters, or specific syntax options may vary slightly, but the overall recovery logic remains the same.

By the end of this article, you will have a complete ready-to-use understanding of how to:

  • Prepare a database for RMAN-based recovery
  • Enable ARCHIVELOG mode correctly
  • Configure storage-related prerequisites such as FRA
  • Take a full compressed RMAN backup including archived redo logs
  • Validate the backup
  • Restore the database to another host
  • Handle common issues such as missing audit directories or missing archived logs
  • Decide whether to open normally or with RESETLOGS

2. Requirements Before Taking the Backup

Before you run any RMAN backup, the environment must be prepared correctly. A backup job may complete successfully even in a poorly prepared environment, but when restore time comes, those missing preparation steps become serious recovery problems. That is why this section is critical.

2.1 Why ARCHIVELOG Mode Matters

If you want the ability to recover the database beyond the exact time of the last clean shutdown backup, you must run the database in ARCHIVELOG mode. This is especially important for:

  • Point-in-time recovery
  • Online backups while the database is open
  • Recovery after media failure
  • Applying archived redo logs after restoring datafiles

Without ARCHIVELOG mode, Oracle does not preserve completed redo log groups for later recovery. That means your restore options are very limited. In most production systems, ARCHIVELOG mode is essential.

You can first check the current database log mode:

SELECT name, log_mode FROM v$database;

If the database is already in ARCHIVELOG, that requirement is satisfied. If it is in NOARCHIVELOG, you must enable ARCHIVELOG mode correctly.

2.2 Correct Procedure to Enable ARCHIVELOG Mode

A common mistake is trying to enable ARCHIVELOG while the database is open. That is not the correct method. Oracle requires the database to be in MOUNT mode before changing the log mode.

Before making this change, make sure an archive log destination has been planned. This can be through a FRA location or through a configured archive destination such as LOG_ARCHIVE_DEST_1.

Use the following sequence:

-- Connect as SYSDBA
sqlplus / as sysdba

-- Optional check before change
ARCHIVE LOG LIST;

-- Shut down the database cleanly
SHUTDOWN IMMEDIATE;

-- Start the instance and mount the database
STARTUP MOUNT;

-- Enable ARCHIVELOG mode
ALTER DATABASE ARCHIVELOG;

-- Open the database
ALTER DATABASE OPEN;

-- Verify the result
ARCHIVE LOG LIST;

This process matters because STARTUP MOUNT opens the control file and prepares the database instance without fully opening the datafiles for user activity. Oracle needs that state to safely switch the redo logging mode.

After enabling ARCHIVELOG mode, the output of ARCHIVE LOG LIST should show that the database is in Archive Mode and that automatic archival is enabled.

2.3 Important Backup Warning After Enabling ARCHIVELOG

Once you switch a database from NOARCHIVELOG to ARCHIVELOG, you should take a fresh full database backup immediately.

This is important because:

  • Old backups taken before the change do not represent the new recovery baseline
  • Future recovery depends on both the backup and the archived redo generated after that backup
  • A clean full backup after enabling ARCHIVELOG establishes a dependable restore point

In simple terms: after enabling ARCHIVELOG, do not rely on older backups. Take a new one.

2.4 Fast Recovery Area (FRA)

Although not strictly mandatory for every environment, configuring a Fast Recovery Area is strongly recommended. FRA gives Oracle a managed storage location for:

  • Archived redo logs
  • RMAN backups
  • Flashback logs
  • Control file autobackups

A sample parameter setup might look like this:

LOG_ARCHIVE_DEST_1='LOCATION=/data/fra'
DB_RECOVERY_FILE_DEST='/data/fra'
DB_RECOVERY_FILE_DEST_SIZE=20G

This means Oracle will use /data/fra as the managed recovery storage location, up to the configured size limit.

Using FRA helps in several ways:

  • Centralizes backup-related storage
  • Simplifies archive log management
  • Supports better operational control
  • Reduces the chance of archive destination misconfiguration

Even if you decide to store your RMAN backup pieces outside FRA, understanding and configuring proper archive storage remains very important.

2.5 Backup Storage Location

Before taking the backup, prepare a dedicated directory for the backup pieces. It is a good practice to use a date-based folder so that each backup run is clearly separated.

Example:

mkdir -p /data/rman/PROD_bkp_$(date +%Y%m%d)
chown -R oracle:oinstall /data/rman/PROD_bkp_$(date +%Y%m%d)
chmod 750 /data/rman/PROD_bkp_$(date +%Y%m%d)

This does three things:

  • Creates the directory
  • Assigns ownership to the Oracle software owner
  • Restricts permissions appropriately

A structured directory naming pattern helps with operational clarity, backup retention, and later transfer to another host.

2.6 Control File Autobackup

The control file contains essential metadata about the database structure, file names, checkpoint information, and RMAN backup records. In recovery scenarios, losing the control file can make restoration far more complicated.

That is why control file autobackup should be enabled:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

When this is enabled, RMAN automatically creates a control file backup after backup operations and structural database changes. That control file backup is essential during disaster recovery, especially when the target server has no existing usable control file.

2.7 Access and Privileges

The backup and restore operations in this guide assume:

  • You are using the Oracle software owner on Linux
  • You have SYSDBA privileges
  • You can connect locally using:
rman target /

This local connection method is simple and common for DBA operations.

2.8 Prepare the Restore Host

If you plan to test the backup by restoring on another server, that target host must also be prepared in advance. It should have:

  • The Oracle software installed
  • A compatible Oracle version, preferably the same major release
  • Enough disk space for the restored database
  • Correct file system structure if you want to restore to the same original paths

3. Taking the RMAN Backup

Once the prerequisites are ready, the next stage is to take the actual backup.

In this guide, the goal is to take:

  • A full database backup
  • Archived redo logs
  • A control file autobackup
  • Compressed backupsets
  • Multiple channels for better throughput

3.1 Create the RMAN Backup Script

Using an RMAN command file is preferable to typing commands manually because it improves:

  • Repeatability
  • Logging consistency
  • Automation readiness
  • Scheduling via cron or other tools

Create a script file such as:

mkdir -p /home/oracle/scripts
vi /home/oracle/scripts/backup_full.cmd

Add the following content:

RUN {
  SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
    '/data/rman/PROD_bkp_%T/control_%F';

  ALLOCATE CHANNEL c1 DEVICE TYPE DISK FORMAT '/data/rman/PROD_bkp_%T/full_%U';
  ALLOCATE CHANNEL c2 DEVICE TYPE DISK FORMAT '/data/rman/PROD_bkp_%T/full_%U';
  ALLOCATE CHANNEL c3 DEVICE TYPE DISK FORMAT '/data/rman/PROD_bkp_%T/full_%U';
  ALLOCATE CHANNEL c4 DEVICE TYPE DISK FORMAT '/data/rman/PROD_bkp_%T/full_%U';

  BACKUP AS COMPRESSED BACKUPSET
    DATABASE
    PLUS ARCHIVELOG;

  RELEASE CHANNEL c1;
  RELEASE CHANNEL c2;
  RELEASE CHANNEL c3;
  RELEASE CHANNEL c4;
}

3.2 Understanding What This Script Does

This script deserves a detailed explanation.

SET CONTROLFILE AUTOBACKUP FORMAT

This tells RMAN where to place the control file autobackup for this run. It uses %T for the date and %F for a unique backup naming pattern.

ALLOCATE CHANNEL

Channels are RMAN’s worker processes. Multiple channels allow parallel reading and writing of backup pieces. In environments with enough I/O capacity, this can reduce backup time significantly.

BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG

This is the heart of the backup.

  • AS COMPRESSED BACKUPSET reduces storage consumption
  • DATABASE backs up the whole database
  • PLUS ARCHIVELOG includes archived redo logs needed for recovery

This is one of the most useful forms of backup for recoverable Oracle systems.

RELEASE CHANNEL

This releases the allocated resources cleanly after the backup ends.

3.3 Execute the RMAN Script

Run the backup from the shell:

rman target / @/home/oracle/scripts/backup_full.cmd \
log=/home/oracle/scripts/backup_full.log

This command:

  • Connects RMAN to the local target database
  • Executes the command file
  • Writes output to a log file

That log file is important for troubleshooting and auditing. In practical operations, always retain backup logs.

3.4 Optional Background Execution

For larger backups, administrators often run RMAN in the background using nohup.

nohup rman target / cmdfile=/home/oracle/scripts/backup_full.cmd \
log=/home/oracle/scripts/backup_full.log &

This allows the process to continue even if the session disconnects.

3.5 Verify the Backup Files

After the backup completes, list the contents of the backup directory:

ls -lh /data/rman/PROD_bkp_$(date +%Y%m%d)

You should see:

  • Several full_... backup pieces
  • A control_... autobackup file

The exact number of backup pieces depends on:

  • Database size
  • Number of channels
  • Compression
  • RMAN piece size behavior

4. Validate the Backup Before Trusting It

One of the best things to do before restoring a backup is validate it.


RMAN>
RESTORE DATABASE VALIDATE;

That is a very good practice.

4.1 Why Validation Matters

A backup file existing on disk does not automatically mean it is restorable. Validation checks that RMAN can read the backup pieces and map them correctly for restore purposes.

Create a small RMAN validation script, for example:

vi /home/oracle/scripts/validate_backup.cmd

Contents:

RESTORE DATABASE VALIDATE;

Run it:

rman target / cmdfile=/home/oracle/scripts/validate_backup.cmd \
log=/home/oracle/scripts/validate_backup.log

If this completes without errors, your backup is much more trustworthy.

4.2 What Validation Proves

It confirms that:

  • RMAN can find the required backup pieces
  • The pieces are readable
  • The backup metadata is usable
  • The restore plan is structurally sound

It does not replace an actual restore test, but it is an important intermediate assurance step.

Note- RESTORE DATABASE VALIDATE; This command doesn’t do a actual restore.

5. Restoring the Backup on Another Server

This section covers the practical restore workflow on a different host. This is often the most valuable part of a DR test because it confirms that the backup can be used outside the original environment.

Lets’s restore the backup on another Linux server using the following general sequence:

  1. Prepare the target server
  2. Start the instance in NOMOUNT
  3. Restore the control file
  4. Mount the database
  5. Catalog the copied backup pieces
  6. Restore the database
  7. Recover the database
  8. Open with RESETLOGS if required

5.1 Prepare the Target Server

On the target host, install the Oracle database software only. Do not create the database manually.

Then create the directory where the copied backup pieces will be placed:

mkdir -p /data/rman/incoming/PROD
chown -R oracle:oinstall /data/rman/incoming/PROD
chmod 750 /data/rman/incoming/PROD

Now transfer the backup pieces from the source host:

rsync -av oracle@primary-host:/data/rman/PROD_bkp_20260318/ /data/rman/incoming/PROD/

Make sure all files are copied, including the control file autobackup.

Note: Ensure the file system structure on the target host matches the original paths if you intend to restore the database files to their original locations.

5.2 Prepare Initialization Parameters and Start in NOMOUNT

To restore the control file, Oracle first needs an instance to be started. For that, you need a PFILE or SPFILE.

A convenient approach is to create a PFILE from the source database SPFILE and move it to the target host.

On the source host:

SQL>

CREATE PFILE='/tmp/initPROD.ora' FROM SPFILE;

Copy that file to the target host, review it, and adjust any parameters if necessary. This is especially important if the Oracle Home or file system layout differs between servers.

Now set the Oracle environment on the target host:

export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
export ORACLE_SID=PROD
export PATH=$ORACLE_HOME/bin:$PATH

Then start the instance:

SQL>

STARTUP NOMOUNT PFILE='/path/to/initPROD.ora';

5.3 Fix ORA-09925 if It Appears

One of the practical issues that may arrise is;

ORA-09925: Unable to create audit trail file

This usually means the audit destination directory defined in the parameter file does not exist on the target host. This can be resolved by creating the required adump directory with correct permissions.

Example fix:

mkdir -p /opt/oracle/admin/PROD/adump
chown -R oracle:oinstall /opt/oracle/admin/PROD
chmod 750 /opt/oracle/admin/PROD/adump

Then retry the STARTUP NOMOUNT command.

5.4 Restore the Control File

Once the instance is up in NOMOUNT, restore the control file from the transferred autobackup.

Example:

RMAN>

RESTORE CONTROLFILE FROM '/data/rman/incoming/PROD/control_c-xxxxxxxxxx-20260318-00';

After restoring the control file, mount the database:

ALTER DATABASE MOUNT;

This step is essential because the control file contains the structure of the database, including datafile metadata and backup references.

5.5 Catalog the Backup Pieces

After moving backup pieces from one server to another, RMAN may not automatically know where those files are located in the new environment. That is why CATALOG START WITH is required.

RMAN >

CATALOG START WITH '/data/rman/incoming/PROD/';

RMAN will scan the directory and identify backup pieces that are not yet known to the repository. It may ask for confirmation before cataloging them.

This step is important because without it, the restore operation may fail simply because RMAN has not been told where the moved pieces now reside.

5.6 Restore the Database

Now that the control file is restored and the backup pieces are cataloged, restore the actual database:

RMAN>

RESTORE DATABASE;

RMAN will restore all required datafiles according to the metadata stored in the control file.

At this stage, Oracle recreates the database files physically on disk. The exact restore duration depends on:

  • Backup size
  • Disk throughput
  • CPU resources
  • Number of channels
  • Compression overhead

5.7 Recover the Database

After restoring the datafiles, the database is still not transactionally consistent. Recovery is required so that archived redo logs can be applied and the database can be brought forward to the correct SCN.

RMAN>

RECOVER DATABASE;

This is where archived redo logs become extremely important.

If all archived logs required for the recovery window are present and accessible, recovery will continue normally.

6. Handling Missing Archived Logs During Recovery

The below is a very common real-world problem during recovery:

RMAN-06054: media recovery requesting unknown archived log

This means RMAN needs an archived redo log that it cannot locate.

6.1 Why This Happens

This error usually occurs when:

  • The required archived log was never backed up
  • The archived log was not transferred to the target
  • The log exists but has not been cataloged
  • The recovery is asking for a sequence beyond what is currently available

6.2 Option 1: Provide the Missing Archived Log

If the missing archived log exists somewhere else, the correct action is to:

  • Copy it to the target server
  • Catalog it if necessary
  • Rerun recovery

This is the preferred solution when you want full recovery to the latest possible point.

6.3 Option 2: Perform Incomplete Recovery

If the missing archived log cannot be obtained, but you still want to open the database at an earlier recoverable point, perform an incomplete recovery.

Example:

RMAN>

RUN {
  SET UNTIL TIME "TO_DATE('2026-03-18 10:00:00','YYYY-MM-DD HH24:MI:SS')";
  RECOVER DATABASE;
}

You can also use SCN or log sequence-based recovery if those values are known.

Incomplete recovery means you are intentionally stopping recovery before the missing redo boundary. This may lead to some data loss, but it allows the database to become usable again.

7. Opening the Database: Normal Open vs RESETLOGS

This is one of the most important decisions in the recovery process.

7.1 Open Normally

If recovery completed fully and Oracle considers the database consistent, open it normally:

ALTER DATABASE OPEN;

7.2 Open with RESETLOGS

If you performed incomplete recovery, or if Oracle requires it after the restore path used, open with:

ALTER DATABASE OPEN RESETLOGS;

7.3 What RESETLOGS Means

Opening with RESETLOGS:

  • Creates a new incarnation of the database
  • Resets redo log sequence numbering
  • Establishes a new recovery baseline

After a RESETLOGS, it is a best practice to take a fresh full backup again as soon as possible.

8. Post-Restore Validation

Once the database is open, the job is not yet complete. You should verify that the restored database is healthy and usable.

A few example checks:

SELECT tablespace_name, status FROM dba_tablespaces;
SELECT COUNT(*) FROM all_objects;

Also verify:

  • Application schemas exist
  • Key tables are accessible
  • Alert log shows no serious issues
  • Archive log generation is functioning
  • Listener and service registration are correct if the host is intended for actual use

9. Best Practices Learned from This Workflow

A strong backup document should not end at commands only. The real value comes from the lessons behind the steps.

Always enable ARCHIVELOG properly

Do not use shortcut commands or incomplete steps. Use SHUTDOWN IMMEDIATE, STARTUP MOUNT, ALTER DATABASE ARCHIVELOG, and then ALTER DATABASE OPEN.

Always take a new full backup after enabling ARCHIVELOG

This becomes your recovery foundation.

Always validate the backup

RESTORE DATABASE VALIDATE is a simple but powerful check.

Always test restore on another host

A backup that has never been restored is only assumed to work.

Always preserve the control file autobackup

That small file becomes critical during disaster recovery.

Always plan for archived redo completeness

The presence of a full backup alone does not guarantee successful recovery to the desired point.

Always document environmental dependencies

Directory structures, Oracle Home paths, audit destinations, and permission settings matter.

10. Conclusion

Oracle RMAN provides a powerful and dependable framework for database backup and recovery, but success depends on correct preparation and disciplined execution. This guide walked through the complete lifecycle of a practical backup and restore workflow:

  • Preparing the environment
  • Enabling ARCHIVELOG correctly
  • Configuring storage and control file safeguards
  • Taking a full compressed RMAN backup with archived logs
  • Validating the backup
  • Transferring the backup to another host
  • Restoring the control file
  • Mounting the database
  • Cataloging backup pieces
  • Restoring and recovering the database
  • Handling missing archive logs
  • Opening the database correctly after recovery

We have already demonstrated a solid operational foundation with the use of compressed backupsets, backup validation, control file restore, cataloging, database restore, recovery, and RESETLOGS. This article expands that base into a cleaner, more complete, and publishable technical guide.

In the end, backup strategy is not only about storing files. It is about being able to recover the database under pressure, with clear steps, minimal confusion, and predictable results. That is why restore testing is just as important as backup execution itself.

A backup is only truly valuable when it has been proven restorable.


메타데이터
post_id
3e9c60504bbc
slug
oracle-database-rman-backup-and-restore-3e9c60504bbc
url
https://medium.com/@buddhikadb1/oracle-database-rman-backup-and-restore-3e9c60504bbc
canonical_url
https://medium.com/@buddhikadb1/oracle-database-rman-backup-and-restore-3e9c60504bbc
author_url
https://medium.com/@buddhikadb1
status
ok
fetched_at
2026-06-21 07:44:09