Rman – Archivelog Backup

I was asked by my manager to take the archivelog backup of a 10.2.0.4 database using RMAN every two hours for a production database on sun solaris.Definitely, i am not going to sit at every 2nd hour and take the backup manually.So,best was to write a shell script and put it in cron job.Cron is a unix, solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon.Now the question was “What will i write in the shell script”.I can set the crontab for every 2 hrs and i can use something like “from time ‘sysdate-1/12’ “.

RMAN> backup as compressed backupset archivelog from time 'sysdate-1/12' format '/oracle_db_storage/testb/arch_070210_%s_%p';

This will check for all the archivelogs generated from 2 hrs back to the current time and take the backup.If suppose i run the command at 11am then it will take the backup of all the archivelogs generated between 9am – 11am.So i can write the script and put it in cron job which runs every 2 hrs and my job is done.Good enough, isn’t it?????

BUT!!!!! what if the cron didn’t run at the time it was supposed to?????? Suppose the cron job didn’t run at 11am, and it ran at the next run cycle that is 1pm, will everything be the same then??? No, cause at 1pm it will backup only those archives which are generated after 11am (current time – 2hrs).I won’t have backup of the archives generated between 9am to 11am.Thats BAD !!!!!!

So, definitely i need to change the script.After few searches with oracle documents i got exactly what i needed

“not backed up integer times ”  :- Backs up only those archived logs that have not been backed up at least integer times.

From Oracle Document :-

notBackedUpSpec

Syntax Element Description
NOT BACKED UP Backs up only those files (of the files specified on the command) that RMAN has never backed up. This option is a convenient way to back up new files after adding them to the database.
SINCE TIME =date_string Specifies the date after which RMAN should back up files that have no backups. The date_string is either a date in the current NLS_DATE_FORMAT, or a SQL date expression such as 'SYSDATE-1'. When calculating the number of backups for a file, RMAN only considers backups created on the same device type as the current backup.This option is a convenient way to back up files that were not backed up during a previous failed backup. For example, you back up the database, but the instance fails halfway through. You can restart the backup with the NOT BACKED UP SINCE TIME clause and avoid backing up those files that you already backed up. If AS BACKUPSET is set, then this feature is only useful if RMAN generates multiple backup sets during the backup.When determining whether a file has been backed up, the SINCE date is compared with the completion time of the most recent backup. For BACKUP AS BACKUPSET, the completion time for a file in a backup set is the completion time of the entire backup set. In other words, all files in the same backup set have the same completion time.
integer TIMES Backs up only those archived logs that have not been backed up at least integer times. To determine the number of backups for a file, RMAN only considers backups created on the same device type as the current backup.

This made my day 🙂 . I tested it on my test db and it worked as needed 🙂

The test was done on 2nd Feb 2010

[oracle@test-testa ~]$  rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Tue Feb 2 10:20:18 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: TESTA (DBID=114007228)

RMAN> list backup of archivelog all;

using target database control file instead of recovery catalog

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

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
944     1.22G      DISK        00:04:22     02-FEB-10
 BP Key: 944   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T021557
 Piece Name: /oracle_db_storage/rman/arch/ARCH_21l4vguu_1_1

 List of Archived Logs in backup set 944
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4209    1014571999 01-FEB-10 1015662867 02-FEB-10
 1    4210    1015662867 02-FEB-10 1016718444 02-FEB-10
 1    4211    1016718444 02-FEB-10 1017788958 02-FEB-10
 1    4212    1017788958 02-FEB-10 1018859257 02-FEB-10
 1    4213    1018859257 02-FEB-10 1019928942 02-FEB-10
 1    4214    1019928942 02-FEB-10 1021002663 02-FEB-10
 1    4215    1021002663 02-FEB-10 1022083432 02-FEB-10
 1    4216    1022083432 02-FEB-10 1022864419 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
945     1.28G      DISK        00:04:31     02-FEB-10
 BP Key: 945   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T021557
 Piece Name: /oracle_db_storage/rman/arch/ARCH_20l4vguu_1_1

 List of Archived Logs in backup set 945
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4201    1011043347 01-FEB-10 1011335909 01-FEB-10
 1    4202    1011335909 01-FEB-10 1011649208 01-FEB-10
 1    4203    1011649208 01-FEB-10 1011963726 01-FEB-10
 1    4204    1011963726 01-FEB-10 1012256376 01-FEB-10
 1    4205    1012256376 01-FEB-10 1012576084 01-FEB-10
 1    4206    1012576084 01-FEB-10 1012877056 01-FEB-10
 1    4207    1012877056 01-FEB-10 1013474586 01-FEB-10
 1    4208    1013474586 01-FEB-10 1014571999 01-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
946     30.82M     DISK        00:00:07     02-FEB-10
 BP Key: 946   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T032714
 Piece Name: /oracle_db_storage/testb/backup/flash_recovery_area/TESTB/backupset/2010_02_02/o1_mf_annnn_TAG20100202T032714_5pj30msg_.bkp

 List of Archived Logs in backup set 946
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4221    1022871009 02-FEB-10 1022925671 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
947     5.77M      DISK        00:00:03     02-FEB-10
 BP Key: 947   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T084620
 Piece Name: /oracle_db_storage/rman/arch/ARCH_1092_1_24l507qs

 List of Archived Logs in backup set 947
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4223    1023209017 02-FEB-10 1023215386 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
948     3.66M      DISK        00:00:02     02-FEB-10
 BP Key: 948   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T084620
 Piece Name: /oracle_db_storage/rman/arch/ARCH_1093_1_25l507r1

 List of Archived Logs in backup set 948
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4217    1022864419 02-FEB-10 1022870971 02-FEB-10
 1    4218    1022870971 02-FEB-10 1022870984 02-FEB-10
 1    4219    1022870984 02-FEB-10 1022870999 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
949     157.76M    DISK        00:00:28     02-FEB-10
 BP Key: 949   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T084620
 Piece Name: /oracle_db_storage/rman/arch/ARCH_1091_1_23l507qs

 List of Archived Logs in backup set 949
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4220    1022870999 02-FEB-10 1022871009 02-FEB-10
 1    4222    1022925671 02-FEB-10 1023209017 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
950     2.22M      DISK        00:00:01     02-FEB-10
 BP Key: 950   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T084810
 Piece Name: /oracle_db_storage/rman/arch/ARCH_1094_1_26l507ua

 List of Archived Logs in backup set 950
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4224    1023215386 02-FEB-10 1023217196 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
951     2.24M      DISK        00:00:01     02-FEB-10
 BP Key: 951   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T085623
 Piece Name: /oracle_db_storage/rman/arch/ARCH_1096_1_28l508dn

 List of Archived Logs in backup set 951
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4225    1023217196 02-FEB-10 1023219527 02-FEB-10
 1    4226    1023219527 02-FEB-10 1023219584 02-FEB-10
 1    4227    1023219584 02-FEB-10 1023219598 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
952     8.10M      DISK        00:00:02     02-FEB-10
 BP Key: 952   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T085623
 Piece Name: /oracle_db_storage/rman/arch/ARCH_1095_1_27l508dn

 List of Archived Logs in backup set 952
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4228    1023219598 02-FEB-10 1023219613 02-FEB-10
 1    4229    1023219613 02-FEB-10 1023228173 02-FEB-10

RMAN> list archivelog all;

List of Archived Log Copies
Key     Thrd Seq     S Low Time  Name
------- ---- ------- - --------- ----
2761    1    4201    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4201_661394635.dbf
2762    1    4202    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4202_661394635.dbf
2763    1    4203    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4203_661394635.dbf
2764    1    4204    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4204_661394635.dbf
2765    1    4205    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4205_661394635.dbf
2766    1    4206    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4206_661394635.dbf
2767    1    4207    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4207_661394635.dbf
2768    1    4208    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4208_661394635.dbf
2769    1    4209    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4209_661394635.dbf
2770    1    4210    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4210_661394635.dbf
2771    1    4211    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4211_661394635.dbf
2772    1    4212    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4212_661394635.dbf
2773    1    4213    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4213_661394635.dbf
2774    1    4214    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4214_661394635.dbf
2775    1    4215    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4215_661394635.dbf
2776    1    4216    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4216_661394635.dbf
2777    1    4217    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4217_661394635.dbf
2778    1    4218    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4218_661394635.dbf
2779    1    4219    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4219_661394635.dbf
2780    1    4220    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4220_661394635.dbf
2781    1    4221    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4221_661394635.dbf
2782    1    4222    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4222_661394635.dbf
2783    1    4223    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4223_661394635.dbf
2784    1    4224    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4224_661394635.dbf
2785    1    4225    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4225_661394635.dbf
2786    1    4226    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4226_661394635.dbf
2787    1    4227    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4227_661394635.dbf
2788    1    4228    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4228_661394635.dbf
2789    1    4229    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4229_661394635.dbf

RMAN>  sql 'alter system switch logfile';

sql statement: alter system switch logfile

RMAN> sql 'alter system switch logfile';

sql statement: alter system switch logfile

RMAN> list archivelog all;

List of Archived Log Copies
Key     Thrd Seq     S Low Time  Name
------- ---- ------- - --------- ----
2761    1    4201    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4201_661394635.dbf
2762    1    4202    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4202_661394635.dbf
2763    1    4203    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4203_661394635.dbf
2764    1    4204    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4204_661394635.dbf
2765    1    4205    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4205_661394635.dbf
2766    1    4206    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4206_661394635.dbf
2767    1    4207    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4207_661394635.dbf
2768    1    4208    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4208_661394635.dbf
2769    1    4209    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4209_661394635.dbf
2770    1    4210    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4210_661394635.dbf
2771    1    4211    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4211_661394635.dbf
2772    1    4212    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4212_661394635.dbf
2773    1    4213    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4213_661394635.dbf
2774    1    4214    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4214_661394635.dbf
2775    1    4215    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4215_661394635.dbf
2776    1    4216    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4216_661394635.dbf
2777    1    4217    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4217_661394635.dbf
2778    1    4218    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4218_661394635.dbf
2779    1    4219    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4219_661394635.dbf
2780    1    4220    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4220_661394635.dbf
2781    1    4221    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4221_661394635.dbf
2782    1    4222    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4222_661394635.dbf
2783    1    4223    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4223_661394635.dbf
2784    1    4224    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4224_661394635.dbf
2785    1    4225    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4225_661394635.dbf
2786    1    4226    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4226_661394635.dbf
2787    1    4227    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4227_661394635.dbf
2788    1    4228    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4228_661394635.dbf
2789    1    4229    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4229_661394635.dbf
2790    1    4230    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4230_661394635.dbf
2791    1    4231    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4231_661394635.dbf

RMAN> backup as compressed backupset archivelog all not backed up 1 times format '/oracle_db_storage/rman/arch/ARCH_%s_%p_%u';

Starting backup at 02-FEB-10
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=933 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=935 devtype=DISK
skipping archive log file /oracle_db_storage/testb/arch/1_4201_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4202_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4203_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4204_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4205_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4206_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4207_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4208_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4209_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4210_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4211_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4212_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4213_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4214_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4215_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4216_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4217_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4218_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4219_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4220_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4221_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4222_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4223_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4224_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4225_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4226_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4227_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4228_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4229_661394635.dbf; already backed up 1 time(s)
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=4230 recid=2790 stamp=709899719
channel ORA_DISK_1: starting piece 1 at 02-FEB-10
channel ORA_DISK_2: starting compressed archive log backupset
channel ORA_DISK_2: specifying archive log(s) in backup set
input archive log thread=1 sequence=4231 recid=2791 stamp=709899719
input archive log thread=1 sequence=4232 recid=2792 stamp=709899830
channel ORA_DISK_2: starting piece 1 at 02-FEB-10
channel ORA_DISK_2: finished piece 1 at 02-FEB-10
piece handle=/oracle_db_storage/rman/arch/ARCH_1098_1_2al50dhm tag=TAG20100202T102350 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: finished piece 1 at 02-FEB-10
piece handle=/oracle_db_storage/rman/arch/ARCH_1097_1_29l50dhm tag=TAG20100202T102350 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:09
Finished backup at 02-FEB-10

RMAN> list backup tag=TAG20100202T102350;

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

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
953     1.18M      DISK        00:00:02     02-FEB-10
 BP Key: 953   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T102350
 Piece Name: /oracle_db_storage/rman/arch/ARCH_1098_1_2al50dhm

 List of Archived Logs in backup set 953
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4231    1023299832 02-FEB-10 1023299888 02-FEB-10
 1    4232    1023299888 02-FEB-10 1023301176 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
954     39.53M     DISK        00:00:08     02-FEB-10
 BP Key: 954   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T102350
 Piece Name: /oracle_db_storage/rman/arch/ARCH_1097_1_29l50dhm

 List of Archived Logs in backup set 954
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    4230    1023228173 02-FEB-10 1023299832 02-FEB-10

Now even if the cron didn’t run due to some reasons, the next time it runs, all the archivelogs that have not been backuped 1 times will be backed up.I won’t miss any archivelog.It was a new learning for me..

Hope this helps someone 🙂

rman target /Recovery Manager: Release 10.2.0.3.0 – Production on Tue Feb 2 10:20:18 2010Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: TESTA (DBID=114007228)

RMAN> list backup of archivelog all;

using target database control file instead of recovery catalog

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

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
944     1.22G      DISK        00:04:22     02-FEB-10
BP Key: 944   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T021557
Piece Name: /oracle_db_storage/rman/arch/ARCH_21l4vguu_1_1

List of Archived Logs in backup set 944
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4209    1014571999 01-FEB-10 1015662867 02-FEB-10
1    4210    1015662867 02-FEB-10 1016718444 02-FEB-10
1    4211    1016718444 02-FEB-10 1017788958 02-FEB-10
1    4212    1017788958 02-FEB-10 1018859257 02-FEB-10
1    4213    1018859257 02-FEB-10 1019928942 02-FEB-10
1    4214    1019928942 02-FEB-10 1021002663 02-FEB-10
1    4215    1021002663 02-FEB-10 1022083432 02-FEB-10
1    4216    1022083432 02-FEB-10 1022864419 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
945     1.28G      DISK        00:04:31     02-FEB-10
BP Key: 945   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T021557
Piece Name: /oracle_db_storage/rman/arch/ARCH_20l4vguu_1_1

List of Archived Logs in backup set 945
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4201    1011043347 01-FEB-10 1011335909 01-FEB-10
1    4202    1011335909 01-FEB-10 1011649208 01-FEB-10
1    4203    1011649208 01-FEB-10 1011963726 01-FEB-10
1    4204    1011963726 01-FEB-10 1012256376 01-FEB-10
1    4205    1012256376 01-FEB-10 1012576084 01-FEB-10
1    4206    1012576084 01-FEB-10 1012877056 01-FEB-10
1    4207    1012877056 01-FEB-10 1013474586 01-FEB-10
1    4208    1013474586 01-FEB-10 1014571999 01-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
946     30.82M     DISK        00:00:07     02-FEB-10
BP Key: 946   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T032714
Piece Name: /oracle_db_storage/testb/backup/flash_recovery_area/TESTB/backupset/2010_02_02/o1_mf_annnn_TAG20100202T032714_5pj30msg_.bkp

List of Archived Logs in backup set 946
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4221    1022871009 02-FEB-10 1022925671 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
947     5.77M      DISK        00:00:03     02-FEB-10
BP Key: 947   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T084620
Piece Name: /oracle_db_storage/rman/arch/ARCH_1092_1_24l507qs

List of Archived Logs in backup set 947
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4223    1023209017 02-FEB-10 1023215386 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
948     3.66M      DISK        00:00:02     02-FEB-10
BP Key: 948   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T084620
Piece Name: /oracle_db_storage/rman/arch/ARCH_1093_1_25l507r1

List of Archived Logs in backup set 948
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4217    1022864419 02-FEB-10 1022870971 02-FEB-10
1    4218    1022870971 02-FEB-10 1022870984 02-FEB-10
1    4219    1022870984 02-FEB-10 1022870999 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
949     157.76M    DISK        00:00:28     02-FEB-10
BP Key: 949   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T084620
Piece Name: /oracle_db_storage/rman/arch/ARCH_1091_1_23l507qs

List of Archived Logs in backup set 949
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4220    1022870999 02-FEB-10 1022871009 02-FEB-10
1    4222    1022925671 02-FEB-10 1023209017 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
950     2.22M      DISK        00:00:01     02-FEB-10
BP Key: 950   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T084810
Piece Name: /oracle_db_storage/rman/arch/ARCH_1094_1_26l507ua

List of Archived Logs in backup set 950
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4224    1023215386 02-FEB-10 1023217196 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
951     2.24M      DISK        00:00:01     02-FEB-10
BP Key: 951   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T085623
Piece Name: /oracle_db_storage/rman/arch/ARCH_1096_1_28l508dn

List of Archived Logs in backup set 951
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4225    1023217196 02-FEB-10 1023219527 02-FEB-10
1    4226    1023219527 02-FEB-10 1023219584 02-FEB-10
1    4227    1023219584 02-FEB-10 1023219598 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
952     8.10M      DISK        00:00:02     02-FEB-10
BP Key: 952   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T085623
Piece Name: /oracle_db_storage/rman/arch/ARCH_1095_1_27l508dn

List of Archived Logs in backup set 952
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4228    1023219598 02-FEB-10 1023219613 02-FEB-10
1    4229    1023219613 02-FEB-10 1023228173 02-FEB-10

RMAN> list archivelog all;

List of Archived Log Copies
Key     Thrd Seq     S Low Time  Name
——- —- ——- – ——— —-
2761    1    4201    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4201_661394635.dbf
2762    1    4202    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4202_661394635.dbf
2763    1    4203    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4203_661394635.dbf
2764    1    4204    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4204_661394635.dbf
2765    1    4205    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4205_661394635.dbf
2766    1    4206    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4206_661394635.dbf
2767    1    4207    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4207_661394635.dbf
2768    1    4208    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4208_661394635.dbf
2769    1    4209    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4209_661394635.dbf
2770    1    4210    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4210_661394635.dbf
2771    1    4211    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4211_661394635.dbf
2772    1    4212    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4212_661394635.dbf
2773    1    4213    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4213_661394635.dbf
2774    1    4214    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4214_661394635.dbf
2775    1    4215    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4215_661394635.dbf
2776    1    4216    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4216_661394635.dbf
2777    1    4217    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4217_661394635.dbf
2778    1    4218    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4218_661394635.dbf
2779    1    4219    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4219_661394635.dbf
2780    1    4220    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4220_661394635.dbf
2781    1    4221    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4221_661394635.dbf
2782    1    4222    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4222_661394635.dbf
2783    1    4223    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4223_661394635.dbf
2784    1    4224    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4224_661394635.dbf
2785    1    4225    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4225_661394635.dbf
2786    1    4226    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4226_661394635.dbf
2787    1    4227    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4227_661394635.dbf
2788    1    4228    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4228_661394635.dbf
2789    1    4229    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4229_661394635.dbf

RMAN>  sql ‘alter system switch logfile’;

sql statement: alter system switch logfile

RMAN> sql ‘alter system switch logfile’;

sql statement: alter system switch logfile

RMAN> list archivelog all;

List of Archived Log Copies
Key     Thrd Seq     S Low Time  Name
——- —- ——- – ——— —-
2761    1    4201    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4201_661394635.dbf
2762    1    4202    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4202_661394635.dbf
2763    1    4203    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4203_661394635.dbf
2764    1    4204    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4204_661394635.dbf
2765    1    4205    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4205_661394635.dbf
2766    1    4206    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4206_661394635.dbf
2767    1    4207    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4207_661394635.dbf
2768    1    4208    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4208_661394635.dbf
2769    1    4209    A 01-FEB-10 /oracle_db_storage/testb/arch/1_4209_661394635.dbf
2770    1    4210    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4210_661394635.dbf
2771    1    4211    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4211_661394635.dbf
2772    1    4212    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4212_661394635.dbf
2773    1    4213    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4213_661394635.dbf
2774    1    4214    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4214_661394635.dbf
2775    1    4215    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4215_661394635.dbf
2776    1    4216    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4216_661394635.dbf
2777    1    4217    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4217_661394635.dbf
2778    1    4218    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4218_661394635.dbf
2779    1    4219    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4219_661394635.dbf
2780    1    4220    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4220_661394635.dbf
2781    1    4221    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4221_661394635.dbf
2782    1    4222    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4222_661394635.dbf
2783    1    4223    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4223_661394635.dbf
2784    1    4224    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4224_661394635.dbf
2785    1    4225    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4225_661394635.dbf
2786    1    4226    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4226_661394635.dbf
2787    1    4227    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4227_661394635.dbf
2788    1    4228    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4228_661394635.dbf
2789    1    4229    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4229_661394635.dbf
2790    1    4230    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4230_661394635.dbf
2791    1    4231    A 02-FEB-10 /oracle_db_storage/testb/arch/1_4231_661394635.dbf

RMAN> backup as compressed backupset archivelog all not backed up 1 times format ‘/oracle_db_storage/rman/arch/ARCH_%s_%p_%u’;

Starting backup at 02-FEB-10
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=933 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=935 devtype=DISK
skipping archive log file /oracle_db_storage/testb/arch/1_4201_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4202_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4203_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4204_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4205_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4206_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4207_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4208_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4209_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4210_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4211_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4212_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4213_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4214_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4215_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4216_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4217_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4218_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4219_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4220_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4221_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4222_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4223_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4224_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4225_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4226_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4227_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4228_661394635.dbf; already backed up 1 time(s)
skipping archive log file /oracle_db_storage/testb/arch/1_4229_661394635.dbf; already backed up 1 time(s)
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=4230 recid=2790 stamp=709899719
channel ORA_DISK_1: starting piece 1 at 02-FEB-10
channel ORA_DISK_2: starting compressed archive log backupset
channel ORA_DISK_2: specifying archive log(s) in backup set
input archive log thread=1 sequence=4231 recid=2791 stamp=709899719
input archive log thread=1 sequence=4232 recid=2792 stamp=709899830
channel ORA_DISK_2: starting piece 1 at 02-FEB-10
channel ORA_DISK_2: finished piece 1 at 02-FEB-10
piece handle=/oracle_db_storage/rman/arch/ARCH_1098_1_2al50dhm tag=TAG20100202T102350 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: finished piece 1 at 02-FEB-10
piece handle=/oracle_db_storage/rman/arch/ARCH_1097_1_29l50dhm tag=TAG20100202T102350 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:09
Finished backup at 02-FEB-10

RMAN> list backup tag=TAG20100202T102350;

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

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
953     1.18M      DISK        00:00:02     02-FEB-10
BP Key: 953   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T102350
Piece Name: /oracle_db_storage/rman/arch/ARCH_1098_1_2al50dhm

List of Archived Logs in backup set 953
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4231    1023299832 02-FEB-10 1023299888 02-FEB-10
1    4232    1023299888 02-FEB-10 1023301176 02-FEB-10

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
954     39.53M     DISK        00:00:08     02-FEB-10
BP Key: 954   Status: AVAILABLE  Compressed: YES  Tag: TAG20100202T102350
Piece Name: /oracle_db_storage/rman/arch/ARCH_1097_1_29l50dhm

List of Archived Logs in backup set 954
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    4230    1023228173 02-FEB-10 1023299832 02-FEB-10

[oracle@aires-testb arch]$ ls -lrt
total 2848536
-rw-r—– 1 oracle oinstall 1312723456 Feb  2 02:20 ARCH_21l4vguu_1_1
-rw-r—– 1 oracle oinstall 1370094592 Feb  2 02:20 ARCH_20l4vguu_1_1
-rw-r—– 1 oracle oinstall    6048256 Feb  2 08:46 ARCH_1092_1_24l507qs
-rw-r—– 1 oracle oinstall    3837952 Feb  2 08:46 ARCH_1093_1_25l507r1
-rw-r—– 1 oracle oinstall  165422592 Feb  2 08:46 ARCH_1091_1_23l507qs
-rw-r—– 1 oracle oinstall    2329600 Feb  2 08:48 ARCH_1094_1_26l507ua
-rw-r—– 1 oracle oinstall    2351616 Feb  2 08:56 ARCH_1096_1_28l508dn
-rw-r—– 1 oracle oinstall    8492544 Feb  2 08:56 ARCH_1095_1_27l508dn
-rw-r—– 1 oracle oinstall    1239040 Feb  2 10:23 ARCH_1098_1_2al50dhm
-rw-r—– 1 oracle oinstall   41454592 Feb  2 10:23 ARCH_1097_1_29l50dhm
[oracle@aires-testb arch]$

2 thoughts on “Rman – Archivelog Backup

  1. One thing you might want to try as well is this rman script:
    (script)
    sql ‘alter system switch logfile’;
    backup archivelog all delete input;
    (/script)
    This switches the logfile at start of backup, then backs up all logs and deletes them. Next time you run this, no matter how much later, it will only backup anything created since.

    1. Hi Nuno,

      Thanks for visiting my blog and putting a nice suggestion.I haven’t written the full script in the blog, have just showed the major part of change in the script.But yes before the backup starts ‘alter system archive log current’ is fired and then the backup starts.

      Regards,
      Anand

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s