Setting and Deleting Oracle RMAN Retention Policies

English

In Oracle Database backup management, the RMAN retention policy is a core feature for preventing storage depletion while ensuring the necessary recovery period. This article explains how to efficiently set backup retention rules using RMAN (Recovery Manager), verify settings with SHOW ALL, and perform deletion procedures for obsolete files in a way that is easy for beginners to understand.

Conclusion: What to do with RMAN Retention Policies

To automate backup operations, implementing the following three steps is the shortest path:

  1. Decide on a Policy: Determine whether you want to go back a certain number of days (period) or keep a certain number of copies (count).
  2. Configure and Verify: Use CONFIGURE to set the policy and SHOW ALL to check consistency with other parameters.
  3. Delete Obsolete Files: Incorporate the DELETE OBSOLETE command into your operational scripts.

What is an RMAN Retention Policy?

An RMAN Retention Policy is a rule that defines “how long a backup file is considered valid.”

By setting this policy appropriately, RMAN marks files that are no longer needed for recovery with the status OBSOLETE. This allows administrators to safely optimize storage without having to individually judge which files can be deleted.

Two Types of Retention Policies

In Oracle 19c, you generally choose between two types of retention policies: “Period” or “Redundancy.”

1. Recovery Window-based (Specifying a Period)

This maintains the ability to perform recovery (incomplete recovery) to any point in time within the specified number of days.

  • Benefit: Management directly linked to business requirements, such as “wanting to restore to the state from one week ago.”
  • Configuration Example: To enable recovery for the past 7 days.
-- Maintain a state where recovery to any point within the last 7 days is possible
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

2. Redundancy-based (Specifying Generations)

This retains a specified number of backup copies (count).

  • Benefit: Makes it easier to predict storage consumption and is suitable for simple operations.
  • Configuration Example: To retain the latest 2 generations of backups.
-- Retain 2 copies counting from the latest (default is 1)
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

Implementation Steps: From Configuration Verification to Deletion

Prerequisites

  • Execution Environment: Oracle Database 19c (Applicable to both CDB/PDB)
  • Required Privileges: SYSDBA or SYSBACKUP

STEP 1: Understand All Settings with SHOW ALL

Instead of looking only at the retention policy, execute SHOW ALL to check the optimization status of the entire backup configuration.

-- Connect to RMAN
rman target /

-- Display all configuration parameters
RMAN> SHOW ALL;

When you execute SHOW ALL, a list of current settings is displayed as follows:

RMAN> show all;

リカバリ・カタログのかわりにターゲット・データベース制御ファイルを使用しています
db_unique_name V19のデータベースにおけるRMAN構成パラメータ:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/19.0.0/dbhome_1/dbs/snapcf_v19.f'; # default

RMAN>

Items followed by # default at the end are parameters that remain at their initial settings.

STEP 2: Change the Policy

Execute the command according to your environment.

-- Example: To ensure a recovery period of 30 days
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS;

STEP 3: Delete Obsolete Backups

Physically delete the files judged as unnecessary (OBSOLETE) based on the policy.

-- Check the list of candidates for deletion (no deletion occurs)
RMAN> REPORT OBSOLETE;

-- Delete all obsolete files at once
RMAN> DELETE OBSOLETE;
[oracle@v19single ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on 日 2月 2 23:59:05 2025
Version 19.21.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

ターゲット・データベース: V19 (DBID=2957249400)に接続されました

RMAN> delete obsolete; ★保存ポリシーを参照し、不要なファイルを自動で削除

リカバリ・カタログのかわりにターゲット・データベース制御ファイルを使用しています
Recovery Manager保存ポリシーがコマンドに適用されます。
Recovery Manager保存ポリシーが冗長性1に設定されます。
チャネル: ORA_DISK_1が割り当てられました
チャネルORA_DISK_1: SID=95 デバイス・タイプ=DISK
次の不要なバックアップおよびコピーが削除されます:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
アーカイブ・ログ 1 25-02-02 /u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_12_msz10jwr_.arc
アーカイブ・ログ 2 25-02-02 /u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_13_msz10mhy_.arc
アーカイブ・ログ 3 25-02-02 /u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_14_msz10q84_.arc
アーカイブ・ログ 4 25-02-02 /u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_15_msz11kr0_.arc
バックアップ・セット 1 25-02-02
バックアップ・ピース 1 25-02-02 /u01/app/oracle/fast_recovery_area/V19/backupset/2025_02_02/o1_mf_annnn_TAG20250202T234154_msz11lmk_.bkp
バックアップ・セット 2 25-02-02
バックアップ・ピース 2 25-02-02 /u01/app/oracle/fast_recovery_area/V19/backupset/2025_02_02/o1_mf_nnndf_TAG20250202T234155_msz11myr_.bkp
アーカイブ・ログ 5 25-02-02 /u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_16_msz12f2l_.arc
バックアップ・セット 3 25-02-02
バックアップ・ピース 3 25-02-02 /u01/app/oracle/fast_recovery_area/V19/backupset/2025_02_02/o1_mf_annnn_TAG20250202T234221_msz12f8m_.bkp
バックアップ・セット 4 25-02-02
バックアップ・ピース 4 25-02-02 /u01/app/oracle/fast_recovery_area/V19/autobackup/2025_02_02/o1_mf_s_1192059742_msz12glj_.bkp
アーカイブ・ログ 6 25-02-02 /u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_17_msz12tg4_.arc
バックアップ・セット 5 25-02-02
バックアップ・ピース 5 25-02-02 /u01/app/oracle/fast_recovery_area/V19/backupset/2025_02_02/o1_mf_annnn_TAG20250202T234234_msz12tnr_.bkp

このオブジェクトを削除しますか(YESまたはNOを入力してください)。 yes
アーカイブ・ログを削除しました
アーカイブ・ログ・ファイル名=/u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_12_msz10jwr_.arc レコードID=1 スタンプ=1192059681
アーカイブ・ログを削除しました
アーカイブ・ログ・ファイル名=/u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_13_msz10mhy_.arc レコードID=2 スタンプ=1192059683
アーカイブ・ログを削除しました
アーカイブ・ログ・ファイル名=/u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_14_msz10q84_.arc レコードID=3 スタンプ=1192059687
アーカイブ・ログを削除しました
アーカイブ・ログ・ファイル名=/u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_15_msz11kr0_.arc レコードID=4 スタンプ=1192059713
バックアップ・ピースが削除されました
バックアップ・ピース・ハンドル=/u01/app/oracle/fast_recovery_area/V19/backupset/2025_02_02/o1_mf_annnn_TAG20250202T234154_msz11lmk_.bkp レコードID=1 スタンプ=1192059714
バックアップ・ピースが削除されました
バックアップ・ピース・ハンドル=/u01/app/oracle/fast_recovery_area/V19/backupset/2025_02_02/o1_mf_nnndf_TAG20250202T234155_msz11myr_.bkp レコードID=2 スタンプ=1192059715
アーカイブ・ログを削除しました
アーカイブ・ログ・ファイル名=/u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_16_msz12f2l_.arc レコードID=5 スタンプ=1192059741
バックアップ・ピースが削除されました
バックアップ・ピース・ハンドル=/u01/app/oracle/fast_recovery_area/V19/backupset/2025_02_02/o1_mf_annnn_TAG20250202T234221_msz12f8m_.bkp レコードID=3 スタンプ=1192059741
バックアップ・ピースが削除されました
バックアップ・ピース・ハンドル=/u01/app/oracle/fast_recovery_area/V19/autobackup/2025_02_02/o1_mf_s_1192059742_msz12glj_.bkp レコードID=4 スタンプ=1192059742
アーカイブ・ログを削除しました
アーカイブ・ログ・ファイル名=/u01/app/oracle/fast_recovery_area/V19/archivelog/2025_02_02/o1_mf_1_17_msz12tg4_.arc レコードID=6 スタンプ=1192059754
バックアップ・ピースが削除されました
バックアップ・ピース・ハンドル=/u01/app/oracle/fast_recovery_area/V19/backupset/2025_02_02/o1_mf_annnn_TAG20250202T234234_msz12tnr_.bkp レコードID=5 スタンプ=1192059754
11オブジェクトを削除しました


RMAN>

Troubleshooting: Common ORA Errors

These are problems and solutions that frequently occur regarding retention policies.

Error CodeCauseAction
ORA-19809Exceeded Fast Recovery Area (FRA) limitExecute DELETE OBSOLETE or expand the FRA size.
ORA-19815Capacity full due to archive logs, etc.Do not delete manually; always perform DELETE via RMAN.

Operational Notes and Security

  • The Pitfall of Automatic Deletion: Files are not deleted unless the DELETE OBSOLETE command is executed. Be sure to add this command to the end of your backup jobs.
  • How to Reset (Initialize to Default):
-- Reset to initial setting (Redundancy 1)
CONFIGURE RETENTION POLICY CLEAR;
  • Reference Alternative: Getting into the habit of checking targets with REPORT OBSOLETE before physical deletion can prevent unintended deletion errors.

FAQ

Q1: What is the difference between SHOW ALL and SHOW RETENTION POLICY?

A1: SHOW ALL displays all settings, including backup destinations and optimization settings, while SHOW RETENTION POLICY extracts and displays only the retention policy.

Q2: Will disk space be freed automatically if I set a retention policy?

A2: No. The policy only determines “what can be deleted.” To actually delete them, execution of the DELETE OBSOLETE command is required.

Q3: Are archive logs also deleted?

A3: Yes. Archive logs that are no longer needed for recovery within the set period or generation are also included in the deletion targets for DELETE OBSOLETE.

Summary

  • The SHOW ALL command allows you to check the entire RMAN configuration, including the retention policy.
  • Recovery Window defines retention rules by “period,” and Redundancy defines them by “generation.”
  • Use CONFIGURE RETENTION POLICY for settings.
  • Regular DELETE OBSOLETE is essential to secure free space.

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

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

コメント

Copied title and URL