سؤال

I am doing a level 0 (full) incremental backup on Sundays, with the following global script:

printing stored global script: weekly_backup
{
        allocate channel DISK1 device type disk format '&1/&2_Disk1_%U.bkp';
        allocate channel DISK2 device type disk format '&1/&2_Disk2_%U.bkp';
        allocate channel DISK3 device type disk format '&1/&2_Disk3_%U.bkp';
        backup section size 1g incremental level 0  as compressed backupset
                tag '&2'
                keep until time 'SYSDATE+&3'
                restore point '&2'
                database plus archivelog;
        delete noprompt obsolete;
}

And Monday through Saturday I run the following RMAN commands for a level 1 incremental backup:

run {
        backup section size 1g incremental level 1  as compressed backupset archivelog all database;
        delete noprompt obsolete;
}

My significant settings:

RMAN> show all;

RMAN configuration parameters for database with db_unique_name RCATN are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

Now when I invoke my script with a parameter of 15 for days, my level 0 backupsets have the appropriate values for Keep:

(All the rest of these commands I ran on 28-Mar 2019)

RMAN> list backupset tag=L0_2019_03_17;


List of Backup Sets
===================


BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
4349986 7.90M      DISK        00:00:01     2019-03-17 02:05:12
        BP Key: 4349990   Status: AVAILABLE  Compressed: YES  Tag: L0_2019_03_17
        Piece Name: /mnt/shares/backup/RCATN/L0_2019_03_17_Disk2_sgtskh2n_1_1.bkp
        Keep: BACKUP_LOGS        Until: 2019-04-01 02:05:11
...

But when I list out all backupsets, it shows I have several days' worth of level 1 incremental backups that are older than my oldest level 0 (full) backup:

RMAN> list backupset summary;


List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
4324675 B  1  A DISK        2019-03-07      2       1       YES        TAG20190307T020510
4324676 B  0  A DISK        2019-03-07      1       1       YES        TAG20190307T020510
4324677 B  1  A DISK        2019-03-07      1       1       YES        TAG20190307T020510
4325630 B  A  A DISK        2019-03-07      1       1       NO         TAG20190307T120513
4326388 B  A  A DISK        2019-03-08      1       1       NO         TAG20190308T000512
4326760 B  A  A DISK        2019-03-08      1       1       YES        TAG20190308T020510
4326761 B  1  A DISK        2019-03-08      1       1       YES        TAG20190308T020510
4326762 B  1  A DISK        2019-03-08      2       1       YES        TAG20190308T020510
4327695 B  A  A DISK        2019-03-08      1       1       NO         TAG20190308T120513
4332857 B  A  A DISK        2019-03-09      1       1       NO         TAG20190309T000508
4333313 B  A  A DISK        2019-03-09      1       1       YES        TAG20190309T020508
4333314 B  1  A DISK        2019-03-09      1       1       YES        TAG20190309T020508
4333315 B  1  A DISK        2019-03-09      2       1       YES        TAG20190309T020508
4334294 B  A  A DISK        2019-03-09      1       1       NO         TAG20190309T120512
4335404 B  A  A DISK        2019-03-11      1       1       NO         TAG20190311T000508
4335904 B  A  A DISK        2019-03-11      1       1       YES        TAG20190311T020509
4335905 B  1  A DISK        2019-03-11      1       1       YES        TAG20190311T020509
4335906 B  1  A DISK        2019-03-11      2       1       YES        TAG20190311T020509
4336825 B  A  A DISK        2019-03-11      1       1       NO         TAG20190311T120508
4337610 B  A  A DISK        2019-03-12      1       1       NO         TAG20190312T000508
4338006 B  A  A DISK        2019-03-12      1       1       YES        TAG20190312T020509
4338007 B  1  A DISK        2019-03-12      1       1       YES        TAG20190312T020509
4338008 B  1  A DISK        2019-03-12      2       1       YES        TAG20190312T020509
4338956 B  A  A DISK        2019-03-12      1       1       NO         TAG20190312T120508
4339810 B  A  A DISK        2019-03-13      1       1       NO         TAG20190313T000508
4340248 B  A  A DISK        2019-03-13      1       1       YES        TAG20190313T020507
4340249 B  1  A DISK        2019-03-13      1       1       YES        TAG20190313T020507
4340250 B  1  A DISK        2019-03-13      2       1       YES        TAG20190313T020507
4341190 B  A  A DISK        2019-03-13      1       1       NO         TAG20190313T120508
4342684 B  A  A DISK        2019-03-14      1       1       NO         TAG20190314T000508
4343074 B  A  A DISK        2019-03-14      1       1       YES        TAG20190314T020508
4343075 B  1  A DISK        2019-03-14      1       1       YES        TAG20190314T020508
4343076 B  1  A DISK        2019-03-14      2       1       YES        TAG20190314T020508
4344192 B  A  A DISK        2019-03-14      1       1       NO         TAG20190314T120508
4345115 B  A  A DISK        2019-03-15      1       1       NO         TAG20190315T000509
4345510 B  A  A DISK        2019-03-15      1       1       YES        TAG20190315T020508
4345511 B  1  A DISK        2019-03-15      1       1       YES        TAG20190315T020508
4345512 B  1  A DISK        2019-03-15      2       1       YES        TAG20190315T020508
4346447 B  A  A DISK        2019-03-15      1       1       NO         TAG20190315T120508
4347266 B  A  A DISK        2019-03-16      1       1       NO         TAG20190316T000509
4347630 B  A  A DISK        2019-03-16      1       1       YES        TAG20190316T020508
4347631 B  1  A DISK        2019-03-16      1       1       YES        TAG20190316T020508
4347632 B  1  A DISK        2019-03-16      2       1       YES        TAG20190316T020508
4348621 B  A  A DISK        2019-03-16      1       1       NO         TAG20190316T120509
4349564 B  A  A DISK        2019-03-17      1       1       NO         TAG20190317T000509
4349986 B  A  A DISK        2019-03-17      1       1       YES        L0_2019_03_17
4349987 B  A  A DISK        2019-03-17      1       1       YES        L0_2019_03_17
4350036 B  0  A DISK        2019-03-17      1       1       YES        L0_2019_03_17
4350037 B  0  A DISK        2019-03-17      1       1       YES        L0_2019_03_17
4350038 B  0  A DISK        2019-03-17      1       1       YES        L0_2019_03_17
4350039 B  0  A DISK        2019-03-17      2       1       YES        L0_2019_03_17
4350061 B  A  A DISK        2019-03-17      1       1       YES        L0_2019_03_17
4350062 B  A  A DISK        2019-03-17      1       1       YES        L0_2019_03_17
4350079 B  F  A DISK        2019-03-17      1       1       YES        L0_2019_03_17
4350097 B  F  A DISK        2019-03-17      1       1       YES        L0_2019_03_17
4350114 B  A  A DISK        2019-03-17      1       1       YES        L0_2019_03_17
4351780 B  A  A DISK        2019-03-17      1       1       NO         TAG20190317T120509
4352876 B  A  A DISK        2019-03-18      1       1       NO         TAG20190318T000508
4353260 B  A  A DISK        2019-03-18      1       1       YES        TAG20190318T020508
4353261 B  1  A DISK        2019-03-18      1       1       YES        TAG20190318T020508
4353262 B  1  A DISK        2019-03-18      2       1       YES        TAG20190318T020508
4354185 B  A  A DISK        2019-03-18      1       1       NO         TAG20190318T120508
...

And if I list out the details of a level 1 incremental backup (I picked the first one in the summary list above), I don't see any KEEP data:

RMAN> list backupset 4324675;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4324675 Incr 1  380.61M    DISK        00:01:15     2019-03-07
  List of Datafiles in backup set 4324675
  File LV Type Ckp SCN    Ckp Time   Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- ---------- ----------- ------ ----
  3    0  Incr 40466491   2019-03-07              NO    /u01/app/oracle/oradata/rmcat/sysaux01.dbf

  Backup Set Copy #1 of backup set 4324675
  Device Type Elapsed Time Completion Time Compressed Tag
  ----------- ------------ --------------- ---------- ---
  DISK        00:01:15     2019-03-07      YES        TAG20190307T020510

    List of Backup Pieces for backup set 4324675 Copy #1
    BP Key  Pc# Status      Piece Name
    ------- --- ----------- ----------
    4324680 1   AVAILABLE   /u01/app/oracle/recovery_area/RCATN/backupset/2019_03_07/o1_mf_nnnd1_TAG20190307T020510_g80vlp4r_.bkp
    4324681 2   AVAILABLE   /u01/app/oracle/recovery_area/RCATN/backupset/2019_03_07/o1_mf_nnnd1_TAG20190307T020510_g80vn3cq_.bkp

RMAN>

So why is RMAN keeping level 1 backups that are older than my oldest level 0 backup?

هل كانت مفيدة؟

المحلول

According to the Backup and Recovery Reference, explanation of the KEEP option:

Usage Notes

RMAN does not consider backup pieces with the KEEP option when computing the backup retention policy. If available, RMAN uses these backups for disaster recovery restore operations, but their purpose is to produce a snapshot of the database that can be restored on another system for testing or historical usage.

So when was the last full or inc0 backup you took without the KEEP option? All inc1 and archivelogs since then are still calculated as being needed to enforce the recovery window and so are not obsolete.

Transferred from comments:

So, if I want to keep my weekly level 0 backups for production for 2 months and only keep my incremental level 1 backups for a week, what's the easiest way to accomplish that?

There's no point in keeping your inc0 for 2 months when keeping inc1 for only a week. They work together.

The first thing you need to do is change your RETENTION_POLICY from REDUNDANCY to RECOVERY_WINDOW. Then simply include a DELETE OBSOLETE in every backup job, and let RMAN work out what can and cannot be deleted. And remember that those archival backups will be deemed obsolete by their KEEP UNTIL <date>, not the RETENTION POLICY.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى dba.stackexchange
scroll top