Specifying Oracle RMAN Backup Destinations and Filenames (FORMAT Clause)

English

In Oracle Database operations, backup management using RMAN (Recovery Manager) is indispensable. However, using default settings may result in backup files being created in unintended directories or making it difficult to identify filenames.

This article provides a clear explanation of how to use the FORMAT clause to determine the output device, directory, and unique filenames for backups using Oracle RMAN, based on 19c specifications.

Conclusion: Quick Steps for RMAN Backup Operations

The following is a “To-Do List” for performing backups to a specific directory with unique filenames:

  1. Create the Output Directory: Ensure the OS user (oracle) has write permissions.
  2. Utilize the FORMAT Clause: Specify the path and placeholders when executing the BACKUP command.
  3. Permanent Configuration (Optional): Use CONFIGURE CHANNEL to fix the default output destination.
  4. Autobackup Settings: Also verify the output destination for the control file and SPFILE.

Background and Basics: Why Specify the Output Destination?

By default, RMAN creates backups in the Fast Recovery Area (FRA) or a platform-specific default location (such as $ORACLE_HOME/dbs).

However, for managing disk capacity or operations involving transferring backup files to external storage, it is strongly recommended to explicitly specify directories and use filenames (placeholders) that make the content identifiable at a glance.

Procedures and Implementation: How to Specify Destination and Filename

1. Specifying the Output Device (DISK or SBT)

In RMAN, you choose the backup destination between “Disk” or “Tape (SBT).”

  • DISK: Local disks or file systems such as NFS.
  • SBT: Tape devices or cloud storage via a Media Management Library (MML).

2. Output Directory and Filename Rules

By using placeholders (symbols acting as variables) within the FORMAT clause, you can generate unique filenames.

PlaceholderDescription
%URecommended. Includes a system-generated unique identifier (8 characters or more).
%dDatabase name (DB_NAME).
%TYear, month, and day (YYYYMMDD).
%tBackup set timestamp.
%sBackup set sequence number.
%pPiece number within the backup set.

Execution Example: RMAN Commands for Copy-and-Paste

The following example uses the /u01/app/oracle/backup/ directory in a Linux environment.

Note: Execution requires SYSBACKUP or SYSDBA privileges.

Performing a Backup to a Specific Directory

This is the most standard example of taking a backup with non-duplicate filenames using %U.

-- Directory creation and permission assignment on the OS are required beforehand
-- mkdir -p /u01/app/oracle/backup/
-- chown oracle:oinstall /u01/app/oracle/backup/

BACKUP DATABASE FORMAT '/u01/app/oracle/backup/%U';

Verification of Execution Log and Results:

RMAN> BACKUP DATABASE FORMAT '/u01/app/oracle/backup/%U';  ★

backupを25-02-04で開始しています
リカバリ・カタログのかわりにターゲット・データベース制御ファイルを使用しています
チャネル: ORA_DISK_1が割り当てられました
チャネルORA_DISK_1: SID=96 デバイス・タイプ=DISK
チャネルORA_DISK_1: フル・データファイル・バックアップ・セットを開始しています
チャネルORA_DISK_1: バックアップ・セットにデータファイルを指定しています
入力データファイル ファイル番号=00001 名前=/u01/app/oracle/oradata/V19/system01.dbf
入力データファイル ファイル番号=00003 名前=/u01/app/oracle/oradata/V19/sysaux01.dbf
入力データファイル ファイル番号=00004 名前=/u01/app/oracle/oradata/V19/undotbs01.dbf
入力データファイル ファイル番号=00007 名前=/u01/app/oracle/oradata/V19/users01.dbf
チャネルORA_DISK_1: ピース1 (25-02-04)を起動します
チャネルORA_DISK_1: ピース1 (25-02-04)が完了しました
ピース・ハンドル=/u01/app/oracle/backup/013h020j_1_1_1 タグ=TAG20250204T234938 コメント=NONE
チャネルORA_DISK_1: バックアップ・セットが完了しました。経過時間: 00:00:25
backupを25-02-04で終了しました

Control File and SPFILE Autobackupを25-02-04で開始しています
ピース・ハンドル=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-2957249400-20250204-00 コメント=NONE
Control File and SPFILE Autobackupを25-02-04で終了しました

RMAN> list backup;


バックアップ・セットのリスト
===================


BS Key Type LV Size Device Type Elapsed Time 終了時間
------- ---- -- ---------- ----------- ------------ --------
1 Full 2.26G DISK 00:00:23 25-02-04
BPキー: 1 ステータス: AVAILABLE 圧縮: NO タグ: TAG20250204T234938
ピース名: /u01/app/oracle/backup/013h020j_1_1_1 ★
バックアップ・セット1のデータファイルのリスト
File LV Type Ckp SCN Ckp時間 Abs Fuz SCN Sparse Name
---- -- ---- ---------- -------- ----------- ------ ----
1 Full 2274274 25-02-04 NO /u01/app/oracle/oradata/V19/system01.dbf
3 Full 2274274 25-02-04 NO /u01/app/oracle/oradata/V19/sysaux01.dbf
4 Full 2274274 25-02-04 NO /u01/app/oracle/oradata/V19/undotbs01.dbf
7 Full 2274274 25-02-04 NO /u01/app/oracle/oradata/V19/users01.dbf

BS Key Type LV Size Device Type Elapsed Time 終了時間
------- ---- -- ---------- ----------- ------------ --------
2 Full 10.20M DISK 00:00:00 25-02-04
BPキー: 2 ステータス: AVAILABLE 圧縮: NO タグ: TAG20250204T235004
ピース名: /u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-2957249400-20250204-00
SPFILEも含まれます: 修正時間: 25-02-04
SPFILE db_unique_name: V19
含まれている制御ファイル: Ckp SCN: 2274294 Ckp時間: 25-02-04

Note: A file in the format 013h020j_1_1_1 will be generated in the specified directory. The “piece handle” in the execution result is the actual file path.

Distributed Output to Multiple Directories (Multi-Channel)

When the data volume is large, performance can be improved by allocating multiple channels and distributing the write destinations.

RUN {
    ALLOCATE CHANNEL c1 DEVICE TYPE DISK FORMAT '/u01/app/oracle/backup1/%U';
    ALLOCATE CHANNEL c2 DEVICE TYPE DISK FORMAT '/u02/app/oracle/backup2/%U';
    BACKUP DATABASE;
}

Troubleshooting: Common Errors and Solutions

Error CodeCauseVerification/Action
ORA-19504Failed to create fileVerify the existence of the OS directory and the oracle user’s permissions.
ORA-19505Device identification errorCheck if the specified path is correct or if the disk is mounted.
ORA-27040I/O errorCheck if the directory capacity is insufficient.

Operational Notes: Watch Out for Control File “Autobackup”

Even if you specify FORMAT in the BACKUP DATABASE command, the output destination for the Control File and SPFILE Autobackup does not change. These are output to the FRA or $ORACLE_HOME/dbs by default.

To maintain consistency, it is recommended to perform the following configuration in advance:

-- To also unify the output destination for autobackups
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backup/conf_%F';

FAQ Regarding RMAN Backup Specification

Q: Where are backups saved if the FORMAT clause is not specified?

A: If DB_RECOVERY_FILE_DEST (Fast Recovery Area) is set, they are saved there; otherwise, they are saved to the platform-specific default location (e.g., $ORACLE_HOME/dbs).

Q: Can I use Japanese (multi-byte) characters in the filename?

A: To prevent unexpected behavior at the OS level, use only alphanumeric characters and underscores for RMAN paths and filenames.

Q: What happens if the backup destination disk becomes full?

A: RMAN will output an error and stop. Incorporate operations to delete old backups periodically using the DELETE OBSOLETE command.

Summary

  • Using the FORMAT clause allows you to freely customize backup storage locations and filenames.
  • Always include the %U placeholder to ensure uniqueness.
  • Utilize ALLOCATE CHANNEL for distributing backups across multiple directories.
  • The destination for control file autobackups requires separate configuration via CONFIGURE.

This article targets Oracle Database 19c (screens and default values may vary for other versions).

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

コメント

Copied title and URL