バックアップの保存方針の構成

保存方針

保存方針には冗長性リカバリ期間という相互に排他的な2つオプションがある。

リカバリ期間方針の設定

リカバリ期間とは、現在の時点からリカバリ可能ポイントまでの期間です。1週間のリカバリ期間を構成する場合

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
バックアップ冗長性方針の設定

冗長性に基づく保存方針では、データ・ファイルごとに保持する必要があるバックアップ数を指定する。

CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
保存方針の無効

保存方針を無効にすると、いずれのバックアップも不要とみなされない。

CONFIGURE RETENTION POLICY TO NONE;

保存方針に基づいて不要なバックアップの判断と削除

不要なバックアップの確認 REPORT OBSOLETE
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
 
RMAN> REPORT OBSOLETE;
 
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           2798   09-03-31
  Backup Piece       2802   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_26kb8phf_1_1_20090331.bak
Backup Set           2821   09-03-31
  Backup Piece       2830   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_27kb8pi0_1_1_20090331.bak
Backup Set           2840   09-03-31
  Backup Piece       2842   09-03-31           /u04/app/oracle/oradata/PROD/rman/c-93443355-20090331-00
Backup Set           2883   09-03-31
  Backup Piece       2887   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_29kb8pio_1_1_20090331.bak
Backup Set           2884   09-03-31
  Backup Piece       2888   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_2akb8piq_1_1_20090331.bak
Backup Set           2912   09-03-31
  Backup Piece       2921   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_2bkb8pmn_1_1_20090331.bak
Backup Set           2937   09-03-31
  Backup Piece       2939   09-03-31           /u04/app/oracle/oradata/PROD/rman/c-93443355-20090331-01
Backup Set           3016   09-03-31
  Backup Piece       3020   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_2dkb8pnt_1_1_20090331.bak
 
RMAN>

REPORTまたはDELETEコマンドでREDUNDANCYまたはRECOVERY WINDOWオプションを指定して、構成済の保存方針を無効にすることもできる。
RMAN> REPORT OBSOLETE REDUNDANCY 3;
 
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           2798   09-03-31
  Backup Piece       2802   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_26kb8phf_1_1_20090331.bak
Backup Set           2821   09-03-31
  Backup Piece       2830   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_27kb8pi0_1_1_20090331.bak
Backup Set           2840   09-03-31
  Backup Piece       2842   09-03-31           /u04/app/oracle/oradata/PROD/rman/c-93443355-20090331-00
Backup Set           2883   09-03-31
  Backup Piece       2887   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_29kb8pio_1_1_20090331.bak
 
RMAN> REPORT OBSOLETE RECOVERY WINDOW OF 7 DAYS;
 
no obsolete backups found
 
RMAN>
不要なバックアップの削除 DELETE OBSOLETE

構成済の保存方針を無効にして、不要なバックアップを削除

RMAN> DELETE NOPROMPT OBSOLETE REDUNDANCY 3;
 
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           2798   09-03-31
  Backup Piece       2802   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_26kb8phf_1_1_20090331.bak
Backup Set           2821   09-03-31
  Backup Piece       2830   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_27kb8pi0_1_1_20090331.bak
Backup Set           2840   09-03-31
  Backup Piece       2842   09-03-31           /u04/app/oracle/oradata/PROD/rman/c-93443355-20090331-00
Backup Set           2883   09-03-31
  Backup Piece       2887   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_29kb8pio_1_1_20090331.bak
deleted backup piece
backup piece handle=/u04/app/oracle/oradata/PROD/rman/PROD_26kb8phf_1_1_20090331.bak recid=89 stamp=682911279
deleted backup piece
backup piece handle=/u04/app/oracle/oradata/PROD/rman/PROD_27kb8pi0_1_1_20090331.bak recid=90 stamp=682911297
deleted backup piece
backup piece handle=/u04/app/oracle/oradata/PROD/rman/c-93443355-20090331-00 recid=91 stamp=682911299
deleted backup piece
backup piece handle=/u04/app/oracle/oradata/PROD/rman/PROD_29kb8pio_1_1_20090331.bak recid=92 stamp=682911321
Deleted 4 objects
 
RMAN>

保存方針に基づいて不要なバックアップを削除する。
RMAN> DELETE NOPROMPT OBSOLETE;
 
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           2884   09-03-31
  Backup Piece       2888   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_2akb8piq_1_1_20090331.bak
Backup Set           2912   09-03-31
  Backup Piece       2921   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_2bkb8pmn_1_1_20090331.bak
Backup Set           2937   09-03-31
  Backup Piece       2939   09-03-31           /u04/app/oracle/oradata/PROD/rman/c-93443355-20090331-01
Backup Set           3016   09-03-31
  Backup Piece       3020   09-03-31           /u04/app/oracle/oradata/PROD/rman/PROD_2dkb8pnt_1_1_20090331.bak
deleted backup piece
backup piece handle=/u04/app/oracle/oradata/PROD/rman/PROD_2akb8piq_1_1_20090331.bak recid=93 stamp=682911322
deleted backup piece
backup piece handle=/u04/app/oracle/oradata/PROD/rman/PROD_2bkb8pmn_1_1_20090331.bak recid=94 stamp=682911448
deleted backup piece
backup piece handle=/u04/app/oracle/oradata/PROD/rman/c-93443355-20090331-01 recid=95 stamp=682911451
deleted backup piece
backup piece handle=/u04/app/oracle/oradata/PROD/rman/PROD_2dkb8pnt_1_1_20090331.bak recid=96 stamp=682911486
Deleted 4 objects
 
RMAN>

保存方針からのバックアップの除外

バックアップが長期に保存される場合、保存方針からバックアップを除外する必要がある。

BACKUP DATABASE KEEP UNTIL TIME "TO_DATE('31-DEC-2007' 'dd-mon-yyyy')" NOLOGS;
BACKUP TABLESPACE users KEEP FOREVER NOLOGS;

保存方針からのバックアップの除外を解除する
CHANGE BACKUPSET 2 NOKEEP;
保存方針からのバックアップの除外の使用例
[oracle@db-node01 ~]$ sqlplus / as sysdba    -- DBをマウント状態に変更
 
SQL*Plus: Release 10.2.0.2.0 - Production on331 02:37:12 2009
 
Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
 
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
 
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
 
Total System Global Area  314572800 bytes
Fixed Size                  1260612 bytes
Variable Size              79692732 bytes
Database Buffers          230686720 bytes
Redo Buffers                2932736 bytes
Database mounted.
SQL>
-- RMANに接続し、バックアップを取得
[oracle@db-node01 ~]$ rman target / catalog rman/oracle@OMR
 
Recovery Manager: Release 10.2.0.2.0 - Production on331 02:40:44 2009
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
connected to target database: PROD (DBID=93443355, not open)
connected to recovery catalog database
 
RMAN> backup database keep forever nologs;  -- KEEP FOREVER NOLOGSオプションでバックアップを取る
 
Starting backup at 09-03-31
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=347 devtype=DISK
backup will never be obsolete
archived logs required to recover from this backup will not be kept
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00007 name=/u02/app/oracle/oradata/PROD/example_01.dbf
input datafile fno=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
input datafile fno=00005 name=/u02/app/oracle/oradata/PROD/batch_01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf
input datafile fno=00008 name=/u02/app/oracle/oradata/PROD/oltp_01.dbf
input datafile fno=00006 name=/u02/app/oracle/oradata/PROD/indx_01.dbf
channel ORA_DISK_1: starting piece 1 at 09-03-31
channel ORA_DISK_1: finished piece 1 at 09-03-31
piece handle=/u04/app/oracle/oradata/PROD/rman/PROD_2nkb8tdp_1_1_20090331.bak tag=TAG20090331T024056 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 09-03-31
 
Starting Control File and SPFILE Autobackup at 09-03-31
piece handle=/u04/app/oracle/oradata/PROD/rman/c-93443355-20090331-05 comment=NONE
Finished Control File and SPFILE Autobackup at 09-03-31
 
RMAN> list backupset 3505;    -- バックアップセットの情報確認
 
List of Backup Sets
===================
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3505    Full    42.99M     DISK        00:00:09     09-03-31
        BP Key: 3508   Status: AVAILABLE  Compressed: YES  Tag: TAG20090331T024056
        Piece Name: /u04/app/oracle/oradata/PROD/rman/PROD_2nkb8tdp_1_1_20090331.bak
Keep: NOLOGS             Until: FOREVER        -- KEEP状態になっている。
  List of Datafiles in backup set 3505
  File LV Type Ckp SCN    Ckp Time Name
  ---- -- ---- ---------- -------- ----
  1       Full 286720     09-03-31 /u01/app/oracle/oradata/PROD/system01.dbf
  2       Full 286720     09-03-31 /u01/app/oracle/oradata/PROD/undotbs01.dbf
  3       Full 286720     09-03-31 /u01/app/oracle/oradata/PROD/sysaux01.dbf
  4       Full 286720     09-03-31 /u01/app/oracle/oradata/PROD/users01.dbf
  5       Full 286720     09-03-31 /u02/app/oracle/oradata/PROD/batch_01.dbf
  6       Full 286720     09-03-31 /u02/app/oracle/oradata/PROD/indx_01.dbf
  7       Full 286720     09-03-31 /u02/app/oracle/oradata/PROD/example_01.dbf
  8       Full 286720     09-03-31 /u02/app/oracle/oradata/PROD/oltp_01.dbf
 
RMAN> change backupset 3505 nokeep;    -- バックアップセット3505のKEEP状態を解除
 
using channel ORA_DISK_1
keep attributes for the backup are deleted
backup set key=3505 recid=87 stamp=682915266
RMAN> list backupset 3505;        -- 再度バックアップ3505の情報を確認、バックアップセットのKEEP状態が解除された。
 
List of Backup Sets
===================
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3505    Full    42.99M     DISK        00:00:09     09-03-31
        BP Key: 3508   Status: AVAILABLE  Compressed: YES  Tag: TAG20090331T024056
        Piece Name: /u04/app/oracle/oradata/PROD/rman/PROD_2nkb8tdp_1_1_20090331.bak
  List of Datafiles in backup set 3505
  File LV Type Ckp SCN    Ckp Time Name
  ---- -- ---- ---------- -------- ----
  1       Full 286720     09-03-31 /u01/app/oracle/oradata/PROD/system01.dbf
  2       Full 286720     09-03-31 /u01/app/oracle/oradata/PROD/undotbs01.dbf
  3       Full 286720     09-03-31 /u01/app/oracle/oradata/PROD/sysaux01.dbf
  4       Full 286720     09-03-31 /u01/app/oracle/oradata/PROD/users01.dbf
  5       Full 286720     09-03-31 /u02/app/oracle/oradata/PROD/batch_01.dbf
  6       Full 286720     09-03-31 /u02/app/oracle/oradata/PROD/indx_01.dbf
  7       Full 286720     09-03-31 /u02/app/oracle/oradata/PROD/example_01.dbf
  8       Full 286720     09-03-31 /u02/app/oracle/oradata/PROD/oltp_01.dbf
 
RMAN>

データベースがオープンされた状態で、BACKUP KEEPを実行すると、RMAN-06533が発生してしまう。
そのため、DBをマウントの状態かOPEN READ ONLYにする必要がある。
上記の検証の続き
RMAN> alter database open;
 
database opened
 
RMAN> backup database keep forever nologs;
 
Starting backup at 09-03-31
using channel ORA_DISK_1
backup will never be obsolete
archived logs required to recover from this backup will not be kept
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 03/31/2009 02:48:56
RMAN-06533: KEEP ... NOLOGS option cannot be used when datafiles are fuzzy -- datafile fuzzy状態だからというエラー
RMAN>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License