How to Write an Oracle 19c RMAN Backup Script?

Oracle 19c databases need regular backups to prevent data loss. This guide explains how to create RMAN scripts for full and incremental backups. Learn simple steps to protect your data and keep your business running smoothly.

download-icon
Free Download
for VM, OS, DB, File, NAS, etc.
jack-smith

Updated by Jack Smith on 2026/02/10

Table of contents
  • Prerequisites for RMAN Backup Scripts

  • What is Oracle 19c RMAN Backup?

  • How to Create a Full Database RMAN Backup Script for Oracle 19c

  • How to Create an Incremental RMAN Backup Script for Oracle 19c?

  • Why Automate Oracle 19c Backups?

  • Enterprise-Level Protection With Vinchin Backup & Recovery

  • Frequently Asked Questions About Oracle 19c RMAN Backup Scripts

  • Conclusion

Protecting your Oracle 19c database is not just a best practice—it’s essential for business continuity. A reliable backup script ensures you can recover from hardware failures, data corruption, or accidental deletions with minimal downtime. Oracle’s Recovery Manager (RMAN) is the built-in tool designed for this job. But how do you create a robust and repeatable RMAN backup script for Oracle 19c? Let’s break it down step by step.

Prerequisites for RMAN Backup Scripts

Before writing any backup script in Oracle 19c using RMAN, there are several key requirements to address. These steps lay the foundation for safe and effective backups.

First, your database must be in ARCHIVELOG mode if you want to back up all changes made during normal operation without shutting down the database. To check your current mode, connect to SQL*Plus as a privileged user and run:

ARCHIVE LOG LIST;

If your database is in NOARCHIVELOG mode, only cold backups are possible—meaning you must shut down the database before backing up files to ensure consistency (Oracle Documentation). For most production environments where uptime matters, enable ARCHIVELOG mode following official guidance.

Next comes preparing your backup destination. It’s best practice to use either a dedicated filesystem or Oracle’s Fast Recovery Area (FRA). Make sure there is enough free space by running df -h on Linux systems or checking disk properties on Windows servers. The directory should be owned by the oracle user with correct permissions (chown oracle:dba /your/backup/path). If using FRA, confirm that DB_RECOVERY_FILE_DEST is set appropriately in your parameter file.

For incremental backups—which save time and storage—you should also enable block change tracking (BCT). This feature records changed blocks since the last backup in a small file outside of main datafiles:

ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/u01/oradata/ORCL/bctf.dat';

You can verify BCT status with:

SELECT STATUS FROM V$BLOCK_CHANGE_TRACKING;

Finally, always test connectivity between your server environment variables (ORACLE_HOME, ORACLE_SID, PATH) before automating scripts so that RMAN runs smoothly every time.

What is Oracle 19c RMAN Backup?

RMAN stands for Recovery Manager—a native utility provided by Oracle to handle both backups and restores of databases efficiently (Oracle Docs). In Oracle 19c environments, RMAN supports full backups (copying all data blocks), incremental backups (copying only changed blocks), archived redo log management (capturing ongoing transactions), retention policies (automated cleanup), validation routines (testing restore-ability), and more.

A full backup captures every data block in use within your database at that moment—think of it as taking a snapshot of everything important right now. Incremental backups record only what has changed since the last full or incremental backup; these save time and storage but depend on having an intact baseline image.

By scripting these tasks with RMAN commands saved in text files (.rman), you automate routine work while reducing human error risk—a crucial advantage when managing large production systems or complex recovery objectives.

How to Create a Full Database RMAN Backup Script for Oracle 19c

A full database backup forms the backbone of any disaster recovery plan—without it you cannot perform point-in-time restores or recover from catastrophic loss scenarios.

Start by ensuring ARCHIVELOG mode is enabled as described above; this allows online backups without interrupting users’ access to data.

Prepare your target directory so that it has enough space—remember compressed backups still require significant disk room depending on data volume—and confirm write permissions are set correctly.

Now let’s build out a basic yet robust full backup script called full_backup.rman:

RUN {
  ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;
  ALLOCATE CHANNEL ch2 DEVICE TYPE DISK;
  BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG DELETE INPUT;
  BACKUP CURRENT CONTROLFILE;
  BACKUP SPFILE;
  RELEASE CHANNEL ch1;
  RELEASE CHANNEL ch2;
}

Here’s what happens:

  • Two channels are allocated so that multiple streams can write concurrently—this speeds up large jobs.

  • The command BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG DELETE INPUT creates a compressed copy of all active datafiles plus every archived redo log generated during the process; logs are deleted after successful inclusion in this backupset.

  • Controlfile (BACKUP CURRENT CONTROLFILE) and server parameter file (BACKUP SPFILE) are backed up separately because they’re critical metadata needed during restore operations.

  • Channels are released at completion so system resources aren’t held unnecessarily.

To execute this script interactively:

rman target / @full_backup.rman

Or capture output into an audit log file with timestamped naming:

rman target / log=/u01/backup/log/full_backup_$(date +%Y%m%d_%H%M%S).log @full_backup.rman

After each run:

1. Review logs carefully for any “RMAN-” errors or warnings.

2. Confirm completion messages indicate success (“Finished backup at…”).

3. Optionally validate newly created backupsets using:

   VALIDATE BACKUPSET <backup_piece_name>;

This extra validation step checks physical integrity before relying on those files during an emergency restore event—a simple but powerful safeguard against silent corruption or incomplete jobs.

For advanced setups: consider enabling automatic controlfile autobackup via CONFIGURE CONTROLFILE AUTOBACKUP ON;. This ensures controlfile/SPFILE copies exist even if manual steps get skipped accidentally.

How to Create an Incremental RMAN Backup Script for Oracle 19c?

Incremental backups help optimize both speed and storage usage by copying only what has changed since previous runs—a smart choice when dealing with large databases or tight maintenance windows.

Oracle supports two main types:

  • Level 0: A complete baseline image identical to a full backup

  • Level 1: Only changes since last Level 0 or Level 1

Most organizations schedule weekly Level 0s alongside daily Level 1s; this balances thoroughness with efficiency over time.

Before starting incremental routines:

  • Enable block change tracking if not already done—it dramatically accelerates scan times by letting RMAN skip unchanged blocks quickly.

  • Monitor space usage of BCT files periodically—they grow based on workload patterns but rarely exceed several hundred megabytes unless retention settings are very high.

Here’s how you might structure two separate scripts—for weekly Level 0 (level0_backup.rman) and daily Level 1 (level1_backup.rman):

Level 0 example:

RUN {
 ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;
 ALLOCATE CHANNEL ch2 DEVICE TYPE DISK;
 BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 0 DATABASE PLUS ARCHIVELOG DELETE INPUT;
 BACKUP CURRENT CONTROLFILE;
 BACKUP SPFILE;
 RELEASE CHANNEL ch1;
 RELEASE CHANNEL ch2;
}

Level 1 example:

RUN {
 ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;
 ALLOCATE CHANNEL ch2 DEVICE TYPE DISK;
 BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 1 DATABASE PLUS ARCHIVELOG DELETE INPUT;
 BACKUP CURRENT CONTROLFILE;
 BACKUP SPFILE;
 RELEASE CHANNEL ch1;
 RELEASE CHANNEL ch2;
}

The difference lies mainly in specifying INCREMENTAL LEVEL X, which tells RMAN whether this run should serve as a new baseline (LEVEL 0) or simply capture deltas (LEVEL 1).

Execute these scripts manually like before—or better yet automate them!

Why Automate Oracle 19c Backups?

Manual processes invite mistakes—even seasoned DBAs occasionally miss steps under pressure! Automation ensures regularity regardless of staff availability while freeing skilled personnel from tedious repetition toward higher-value projects instead.

Scripted/scheduled jobs reduce risk across multiple fronts: missed deadlines become rare events rather than common headaches, retention rules get enforced consistently…logs accumulate predictably…and notifications arrive instantly whenever trouble brews behind-the-scenes.

Isn’t peace of mind worth investing those few extra minutes upfront?

Enterprise-Level Protection With Vinchin Backup & Recovery

While manual scripting offers flexibility, many organizations seek greater simplicity and advanced features through specialized solutions. Vinchin Backup & Recovery delivers professional enterprise-level protection supporting today’s mainstream databases—including Oracle, MySQL, SQL Server, MariaDB, PostgreSQL, PostgresPro, and TiDB—with particular strength in safeguarding mission-critical platforms like Oracle databases. Key features such as advanced source-side compression, incremental backup capabilities, batch database processing, flexible GFS/data retention policies, and cloud/tape archiving streamline operations while maximizing efficiency across complex environments—all helping reduce storage costs and accelerate recovery times without sacrificing reliability.

The intuitive web console makes safeguarding Oracle databases straightforward: 

Step 1. Select the Oracle database to back up

Select the Oracle database to back up

Step 2. Choose the backup storage

Choose the backup storage

Step 3. Define the backup strategy

Define the backup strategy

Step 4. Submit the job

Submit the job

Vinchin Backup & Recovery is trusted globally by thousands of enterprises who value its robust security features and ease-of-use interface—experience its top-rated performance yourself with a fully featured free trial valid for sixty days; click below to download now!

Frequently Asked Questions About Oracle 19c RMAN Backup Scripts

Q1: How do I automate daily incremental backups without manual intervention?

A1: Use CRONTAB -E to schedule shell scripts that call your level-specific .rman files automatically each day.

Q2: What should I do if my archive destination fills up during nightly jobs?

A2: Delete unneeded old archives after confirming recent successful backups using LIST ARCHIVELOG ALL in RMAN CLI first.

Q3: How can I quickly check which days had failed versus successful automated runs?

A3: Search timestamped log directories using GREP "ERROR" *.log then review matching entries alongside corresponding dates.

Conclusion

A well-crafted Oracle 19c RMAN backup script protects against costly downtime while supporting fast recovery when needed most.Test both backups and restores regularly.Vinchin makes safeguarding critical databases even easier—try their enterprise-grade solution free today!

Share on:

Categories: Database Backup