| Lesson 3 | RMAN BACKUP command syntax |
| Objective | Identify the syntax of the RMAN BACKUP command. |
Recovery Manager (RMAN) uses the BACKUP command to create backup sets or image copies. The same command can protect an entire container database (CDB), one or more pluggable databases (PDBs), tablespaces, data files, archived redo logs, the current control file, the server parameter file, and existing RMAN backups.
RMAN must be connected to a target database before BACKUP can run. Destination channels can come from persistent CONFIGURE settings or from manual ALLOCATE CHANNEL commands inside a RUN block. This lesson focuses on recognizing the major parts of the command rather than memorizing every branch in Oracle's complete syntax diagrams.
A useful teaching model separates the command into options, an object to protect, object-specific options, and an optional archived-log clause:
BACKUP
[ backup options ]
object-to-back-up
[ object-specific options ]
[ PLUS ARCHIVELOG ];
The exact position of a clause depends on its role in Oracle's formal grammar, but every practical command answers several recognizable questions:
AS BACKUPSET, AS COMPRESSED BACKUPSET, or AS COPY.DEVICE TYPE DISK or DEVICE TYPE SBT.DATABASE, PLUGGABLE DATABASE, TABLESPACE, DATAFILE,
ARCHIVELOG, CURRENT CONTROLFILE, SPFILE, or another supported object.FORMAT, TAG, FILESPERSET, or
SECTION SIZE.SKIP option only when the omission is compatible with the recovery plan.The simplest complete command relies on the configured device, backup type, and naming defaults:
BACKUP DATABASE;
Oracle AI Database 26ai has a preconfigured disk channel. If a fast recovery area is configured and no FORMAT is supplied, RMAN can create
uniquely named disk backup pieces in that recovery area. Persistent settings can change the default device, format, parallelism, and backup type, so review
the active configuration before interpreting a short command:
SHOW ALL;
Manual channel allocation must occur inside a RUN block. The following example explicitly creates a disk channel and a backup set, excludes
read-only data files, and supplies a backup-piece naming pattern:
RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK;
BACKUP AS BACKUPSET
SKIP READONLY
DATABASE
FORMAT '/u03/rman/%d_%T_%U.bkp';
RELEASE CHANNEL c1;
}
Each line has a distinct purpose:
RUN { ... } groups RMAN commands that execute as one job block.ALLOCATE CHANNEL c1 DEVICE TYPE DISK; creates a manual disk channel named c1.BACKUP AS BACKUPSET explicitly selects backup-set output.SKIP READONLY excludes read-only data files from this database backup.DATABASE identifies the complete target CDB as the backup object.FORMAT '/u03/rman/%d_%T_%U.bkp' supplies the disk location and backup-piece naming pattern.RELEASE CHANNEL c1; explicitly releases the manual channel. RMAN also releases it when the RUN block ends.
The image shows both forms because syntax requirements depend on configuration. Manual allocation is useful when a job requires channel-specific settings. It is unnecessary when automatic channels already provide the intended device, location, and behavior.
Use AS BACKUPSET to state explicitly that RMAN should create one or more backup sets:
BACKUP AS BACKUPSET DATABASE;
Use AS COMPRESSED BACKUPSET when the operation should apply RMAN binary compression:
BACKUP AS COMPRESSED BACKUPSET DATABASE;
Use AS COPY to request image copies. Image copies can be written only to disk:
BACKUP AS COPY DATABASE;
An explicit output clause overrides the configured default for that operation. When the clause is omitted, RMAN uses the applicable persistent setting. The default disk backup type is normally an uncompressed backup set unless it has been reconfigured.
The backup specification identifies what RMAN protects. Common examples include:
BACKUP DATABASE;
BACKUP PLUGGABLE DATABASE salespdb;
BACKUP TABLESPACE users;
BACKUP DATAFILE 7;
BACKUP ARCHIVELOG ALL;
BACKUP CURRENT CONTROLFILE;
BACKUP SPFILE;
DATABASE represents the complete target CDB when RMAN is connected to the root. PLUGGABLE DATABASE selects one or more PDBs,
while TABLESPACE and DATAFILE provide narrower scopes. ARCHIVELOG selects archived redo according to the supplied record
criteria.
A connection made only to a PDB limits RMAN operations to that PDB's scope. Archived redo logs belong to the CDB and cannot be included with PLUS ARCHIVELOG from a PDB-only connection. Connect to the CDB root with the required administrative privilege for CDB-level archived-log
operations.
FORMAT specifies a pattern for physical backup-piece names or image-copy names. It is a clause, not a tag. The separate TAG clause
applies a logical label to an RMAN backup.
A FORMAT clause on the overall BACKUP command supplies its general output pattern. A format attached to an individual backup
specification applies to that specification. A format on an allocated or configured channel applies to output written through that channel.
The consolidated image uses this example:
FORMAT '/u03/rman/%d_%T_%U.bkp'
The directory is illustrative. It must exist on the database host, be writable by the Oracle software owner, and have sufficient capacity. When using
Oracle Managed Files in the fast recovery area, omit FORMAT if RMAN should choose the recovery-area location and OMF-style filename.
| Variable | Meaning | Use |
|---|---|---|
%d |
Database name | Identifies the source database |
%T |
Gregorian date in YYYYMMDD format |
Makes the creation date readable |
%U |
System-generated unique filename | Prevents piece-name collisions |
%s |
Backup-set number | Identifies the set |
%p |
Backup-piece number within the set | Identifies the piece |
%t |
Backup-set timestamp value | Provides an internal timestamp component, not a formatted date |
Include %U, or an equivalent combination that guarantees uniqueness, whenever RMAN can create multiple pieces. A fixed filename can cause a later piece or backup to collide with an existing name. This is why the new image replaces the legacy %d%t pattern with %d_%T_%U.
The SKIP clause tells RMAN to omit particular inputs rather than include them or stop for the applicable condition:
BACKUP SKIP OFFLINE DATABASE;
BACKUP SKIP READONLY DATABASE;
BACKUP SKIP INACCESSIBLE DATABASE;
SKIP OFFLINE omits offline data files.SKIP READONLY omits read-only data files.SKIP INACCESSIBLE skips files that RMAN cannot read.SKIP changes the contents of the backup. It does not prove that the excluded files can be recovered. Before excluding read-only or offline files, confirm that usable backups remain within the retention strategy. Treat an inaccessible file as an operational warning that requires investigation, even when the job is intentionally allowed to continue.
The complete Oracle 26ai command supports many additional operands. Learners should recognize the following clauses without trying to memorize the entire railroad diagram:
| Clause | Purpose |
|---|---|
INCREMENTAL LEVEL 0 | Creates an incremental-strategy base |
INCREMENTAL LEVEL 1 | Backs up blocks changed since the applicable parent backup |
CUMULATIVE | Makes level 1 include changes since the most recent level 0 |
DEVICE TYPE DISK | Uses automatic disk channels for the operation |
DEVICE TYPE SBT | Uses a configured media-management or supported cloud interface |
TAG 'name' | Applies a logical label used to identify the backup |
FILESPERSET n | Limits input files included in each backup set |
SECTION SIZE size | Enables multisection processing of large files |
PLUS ARCHIVELOG | Backs up archived redo around the specified operation |
CHECK LOGICAL | Adds logical corruption checking |
VALIDATE | Reads and checks input without creating ordinary backup output |
Level 1 incremental backups use backup-set format. PLUS ARCHIVELOG also has connection-scope and clause-compatibility restrictions, so it
should not be added mechanically to every database command.
The following commands demonstrate recognizable combinations without attempting to cover every specialized option:
BACKUP DATABASE PLUS ARCHIVELOG;
BACKUP AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL 1
DATABASE;
BACKUP PLUGGABLE DATABASE salespdb
TAG 'salespdb_weekly';
BACKUP TABLESPACE users
FORMAT '/u03/rman/users_%T_%U.bkp';
BACKUP ARCHIVELOG ALL;
Syntax validity is only the first requirement for a production backup. The command must also fit the database archiving mode, recovery objectives,
retention policy, destination capacity, encryption policy, and restore-test procedure. In ARCHIVELOG mode, an online database backup normally
requires redo during recovery to make the restored files consistent.
BACKUP DATABASE; is the minimal form when configured defaults are appropriate.RUN block is required for manual ALLOCATE CHANNEL commands.AS BACKUPSET, AS COMPRESSED BACKUPSET, and AS COPY select the output format.FORMAT controls physical naming, while TAG applies a logical RMAN label.SKIP intentionally excludes inputs and must agree with the recovery strategy.The consolidated image identifies the purpose of RUN, ALLOCATE CHANNEL, AS BACKUPSET, SKIP READONLY,
DATABASE, and FORMAT in one complete command.
In the next lesson, you will learn how RMAN combines blocks from multiple input files in a backup piece and how multiplexing affects backup behavior.