This post is related on how to keep a backup forever.
In particular the syntax to have a backup retained forever is using the keep forever option: these kind of backups are also called archival backups, that is a self-contained backups, including all the necessary files (datafiles and archived redo logs) to recreate a consistent backup.
At the same time to successfully complete and maintain a backup forever fewer requisites are required, but let's begin issuing the backup command.
[oracle@vsi08 ~]$ rman target / Recovery Manager: Release 11.2.0.1.0 - Production on Fri Apr 19 12:25:00 2013 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: PROD (DBID=223010867) RMAN> backup database keep forever; Starting backup at 19-04-2013 12:25:27 current log archived using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=17 device type=DISK RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of backup command at 04/19/2013 12:25:28 RMAN-06522: KEEP FOREVER option is not supported without the recovery catalogAs you can deduct from the error message you cannot issue a keep forever option using the target database control file: when using keep forever option you must specify a recovery catalog schema on a dedicated database.
So I'm going to use my new recovery catalog schema on RCAT database.
[oracle@vsi08 ~]$ rman target / catalog rman/rman@RCAT Recovery Manager: Release 11.2.0.1.0 - Production on Fri Apr 19 12:26:07 2013 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: PROD (DBID=223010867) connected to recovery catalog databaseI can issue the same backup command...
RMAN> backup database keep forever; Starting backup at 19-04-2013 12:26:16 current log archived allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=17 device type=DISK backup will never be obsolete archived logs required to recover from this backup will be backed up channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/opt/app/oracle/oradata/PROD/system01.dbf input datafile file number=00002 name=/opt/app/oracle/oradata/PROD/sysaux01.dbf input datafile file number=00003 name=/opt/app/oracle/oradata/PROD/undotbs01.dbf input datafile file number=00004 name=/opt/app/oracle/oradata/PROD/users01.dbf channel ORA_DISK_1: starting piece 1 at 19-04-2013 12:26:18 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of backup command at 04/19/2013 12:26:18 ORA-19811: cannot have files in DB_RECOVERY_FILE_DEST with keep attributes... but it fails once again.
The second restriction while using the keep forever option is related on the flash recovery area: you cannot create those archival backups into the FRA and if you try to do so, the backup fails and an error is thrown.
As you can see I'm currently using a flash recovery area.
SQL> show parameter DB_RECOVERY_FILE_DEST NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_recovery_file_dest string /opt/app/oracle/flash_recovery _area db_recovery_file_dest_size big integer 4977MTo complete my backup I need to use also the format option specifying a directory where creating the archival backups:
RMAN> backup database format '/home/oracle/backup/%U' keep forever; Starting backup at 19-04-2013 12:35:12 current log archived using channel ORA_DISK_1 backup will never be obsolete archived logs required to recover from this backup will be backed up channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/opt/app/oracle/oradata/PROD/system01.dbf input datafile file number=00002 name=/opt/app/oracle/oradata/PROD/sysaux01.dbf input datafile file number=00003 name=/opt/app/oracle/oradata/PROD/undotbs01.dbf input datafile file number=00004 name=/opt/app/oracle/oradata/PROD/users01.dbf channel ORA_DISK_1: starting piece 1 at 19-04-2013 12:35:14 channel ORA_DISK_1: finished piece 1 at 19-04-2013 12:35:59 piece handle=/home/oracle/backup/11o7fhc2_1_1 tag=TAG20130419T123513 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 using channel ORA_DISK_1 backup will never be obsolete archived logs required to recover from this backup will be backed up channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 19-04-2013 12:35:59 channel ORA_DISK_1: finished piece 1 at 19-04-2013 12:36:00 piece handle=/home/oracle/backup/12o7fhdf_1_1 tag=TAG20130419T123513 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 current log archived using channel ORA_DISK_1 backup will never be obsolete archived logs required to recover from this backup will be backed up channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=94 RECID=47 STAMP=813155760 channel ORA_DISK_1: starting piece 1 at 19-04-2013 12:36:01 channel ORA_DISK_1: finished piece 1 at 19-04-2013 12:36:02 piece handle=/home/oracle/backup/13o7fhdh_1_1 tag=TAG20130419T123513 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 using channel ORA_DISK_1 backup will never be obsolete archived logs required to recover from this backup will be backed up channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set channel ORA_DISK_1: starting piece 1 at 19-04-2013 12:36:03 channel ORA_DISK_1: finished piece 1 at 19-04-2013 12:36:05 piece handle=/home/oracle/backup/14o7fhdi_1_1 tag=TAG20130419T123513 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 Finished backup at 19-04-2013 12:36:05Listing the archival backups you can notice a new line after the Piece Name: it says that backup is an archival backup created using the KEEP option and it will be maintained FOREVER. All those archival backups are AVAILABLE, that is RMAN is able to find them on the file system.
RMAN> list backup; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 403 Full 835.42M DISK 00:00:44 19-04-2013 12:35:58 BP Key: 406 Status: AVAILABLE Compressed: NO Tag: TAG20130419T123513 Piece Name: /home/oracle/backup/11o7fhc2_1_1 Keep: BACKUP_LOGS Until: FOREVER List of Datafiles in backup set 403 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- ------------------- ---- 1 Full 1410646 19-04-2013 12:35:14 /opt/app/oracle/oradata/PROD/system01.dbf 2 Full 1410646 19-04-2013 12:35:14 /opt/app/oracle/oradata/PROD/sysaux01.dbf 3 Full 1410646 19-04-2013 12:35:14 /opt/app/oracle/oradata/PROD/undotbs01.dbf 4 Full 1410646 19-04-2013 12:35:14 /opt/app/oracle/oradata/PROD/users01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 404 Full 80.00K DISK 00:00:00 19-04-2013 12:35:59 BP Key: 407 Status: AVAILABLE Compressed: NO Tag: TAG20130419T123513 Piece Name: /home/oracle/backup/12o7fhdf_1_1 Keep: BACKUP_LOGS Until: FOREVER SPFILE Included: Modification time: 19-04-2013 11:18:50 SPFILE db_unique_name: PROD BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ ------------------- 426 2.50K DISK 00:00:00 19-04-2013 12:36:01 BP Key: 429 Status: AVAILABLE Compressed: NO Tag: TAG20130419T123513 Piece Name: /home/oracle/backup/13o7fhdh_1_1 Keep: BACKUP_LOGS Until: FOREVER List of Archived Logs in backup set 426 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- ------------------- ---------- --------- 1 94 1410634 19-04-2013 12:35:13 1410670 19-04-2013 12:36:00 BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 427 Full 9.39M DISK 00:00:02 19-04-2013 12:36:04 BP Key: 430 Status: AVAILABLE Compressed: NO Tag: TAG20130419T123513 Piece Name: /home/oracle/backup/14o7fhdi_1_1 Keep: BACKUP_LOGS Until: FOREVER Control File Included: Ckp SCN: 1410684 Ckp time: 19-04-2013 12:36:02So I have on file system the archival backups, but I want to copy them into a tape library.
[oracle@vsi08 backup]$ pwd /home/oracle/backup [oracle@vsi08 backup]$ ls -lhrt total 846M -rw-r----- 1 oracle oinstall 836M Apr 19 12:35 11o7fhc2_1_1 -rw-r----- 1 oracle oinstall 96K Apr 19 12:35 12o7fhdf_1_1 -rw-r----- 1 oracle oinstall 3.0K Apr 19 12:36 13o7fhdh_1_1 -rw-r----- 1 oracle oinstall 9.5M Apr 19 12:36 14o7fhdi_1_1To complete this task I need to change the backup status to UNAVAILABLE, that is RMAN cannot consider it during a restore and recovery operation: it doesn't exist because I'm going to move it on tape and delete from file system.
RMAN> change backup tag 'TAG20130419T123513' unavailable; changed backup piece unavailable backup piece handle=/home/oracle/backup/11o7fhc2_1_1 RECID=31 STAMP=813155714 changed backup piece unavailable backup piece handle=/home/oracle/backup/12o7fhdf_1_1 RECID=32 STAMP=813155759 changed backup piece unavailable backup piece handle=/home/oracle/backup/13o7fhdh_1_1 RECID=33 STAMP=813155761 changed backup piece unavailable backup piece handle=/home/oracle/backup/14o7fhdi_1_1 RECID=34 STAMP=813155763 Changed 4 objects to UNAVAILABLE statusThe status is now UNAVAILABLE and I can copy the archival backups on tape.
RMAN> list backup; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 403 Full 835.42M DISK 00:00:44 19-04-2013 12:35:58 BP Key: 406 Status: UNAVAILABLE Compressed: NO Tag: TAG20130419T123513 Piece Name: /home/oracle/backup/11o7fhc2_1_1 Keep: BACKUP_LOGS Until: FOREVER List of Datafiles in backup set 403 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- ------------------- ---- 1 Full 1410646 19-04-2013 12:35:14 /opt/app/oracle/oradata/PROD/system01.dbf 2 Full 1410646 19-04-2013 12:35:14 /opt/app/oracle/oradata/PROD/sysaux01.dbf 3 Full 1410646 19-04-2013 12:35:14 /opt/app/oracle/oradata/PROD/undotbs01.dbf 4 Full 1410646 19-04-2013 12:35:14 /opt/app/oracle/oradata/PROD/users01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 404 Full 80.00K DISK 00:00:00 19-04-2013 12:35:59 BP Key: 407 Status: UNAVAILABLE Compressed: NO Tag: TAG20130419T123513 Piece Name: /home/oracle/backup/12o7fhdf_1_1 Keep: BACKUP_LOGS Until: FOREVER SPFILE Included: Modification time: 19-04-2013 11:18:50 SPFILE db_unique_name: PROD BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ ------------------- 426 2.50K DISK 00:00:00 19-04-2013 12:36:01 BP Key: 429 Status: UNAVAILABLE Compressed: NO Tag: TAG20130419T123513 Piece Name: /home/oracle/backup/13o7fhdh_1_1 Keep: BACKUP_LOGS Until: FOREVER List of Archived Logs in backup set 426 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- ------------------- ---------- --------- 1 94 1410634 19-04-2013 12:35:13 1410670 19-04-2013 12:36:00 BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 427 Full 9.39M DISK 00:00:02 19-04-2013 12:36:04 BP Key: 430 Status: UNAVAILABLE Compressed: NO Tag: TAG20130419T123513 Piece Name: /home/oracle/backup/14o7fhdi_1_1 Keep: BACKUP_LOGS Until: FOREVER Control File Included: Ckp SCN: 1410684 Ckp time: 19-04-2013 12:36:02Now it could be possible to copy on a tape and remove from file system these archival backups.
That's all.