RMAN
Backing Up Archived Redolog Files
Archived redo log filesare used during the recovery
process. They contain all the changes made to a database after
backup, so backing up archived redo log files is of vital
importance. If more than one archive destination is declared, RMAN will refer to only one of them and create backup from that
location. If one of the archived redo log files is corrupted at
that location, then RMAN will copy that archived redo log file
from the second location. To backup all archived redo log files
in the database, use this command:
RMAN> backup
archivelog all;
Additionally, backup of archived redo log files may be done
after every backup command. To backup archived redo log files as
an addition to another backup, add the plus archivelog command.
When using PLUS ARCHIVELOG command RMAN
- Archives current redo log file
- Archives all archived redo log file
- Backs up the files which were indicated at the first
part of the command
- Archives current redo log file again
- Backs up all archived redo log files that were
generated during backup
In the following example, a backup of the users tablespace and
all archived redo logs is taken. Before this backup process,
have a look at the list of archived redo log files which were
already created:
SQL>
select
recid, stamp, sequence#, name
from
v$archived_log;
RECID STAMP
SEQUENCE# NAME
------- --------- ---------- ---------------------------------
1 695127182
3
C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2009_08_17\O1_MF_1_3_58KW1XWS_.ARC
2 695127183
2
C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2009_08_17\O1_MF_1_2_58KW1XQX_.ARC
Now create a backup of the users tablespace and all archived
redo log files:
RMAN> backup tablespace users plus
archivelog;
Starting backup at 17-AUG-09
current log archived
#As you see, firstly RMAN archived current online redo log file
<....... output omitted .......>
#Below it defines archived redo log files which will backed up
and archives them as well
input archive log thread=1 sequence=2 recid=2 stamp=695127183
input archive log thread=1 sequence=3 recid=1 stamp=695127182
input archive log thread=1 sequence=4 recid=3 stamp=695127443
piece handle=C:\oracle\product\10.2.0\flash_recovery_area\orcl\backupset\2009_08_17\
o1_mf_annnn_tag20090817t105724_58kwb6k2_.bkp
tag=TAG20090817T105724 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 17-AUG-09
Starting backup at 17-AUG-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
#Backups datafile users01.dbf
input datafile fno=00004 name=C:\oracle\product\10.2.0\oradata\orcl\users01.dbf
channel ORA_DISK_1: starting piece 1 at 17-AUG-09
channel ORA_DISK_1: finished piece 1 at 17-AUG-09
piece handle=C:\ORACLE\product\10.2.0\flash_recovery_area\orcl\backupset\2009_08_17\
o1_mf_nnndf_tag20090817t105729_58kwbb5v_.bkp
tag=TAG20090817T105729 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 17-AUG-09
Starting backup at 17-AUG-09
current log archived
#Archives current online redo log file and backups all archived
redo log files which were created when backup of users tablespace started
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=5 recid=4 stamp=695127451
channel ORA_DISK_1: starting piece 1 at 17-AUG-09
channel ORA_DISK_1: finished piece 1 at 17-AUG-09
piece handle=C:\oracle\product\10.2.0\flash_recovery_area\orcl\backupset\2009_08_17\
o1_mf_annnn_tag20090817t105731_58kwbdws_.bkp
tag=TAG20090817T105731 comment=none
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 17-AUG-09
SQL>
select
recid, stamp, sequence#, name
from
v$archived_log;
RECID STAMP SEQUENCE#
NAME
----- -------- ---------
-------------------------
1 695127182 3 ..\o1_mf_1_3_58kw1xws_.arc
2 695127183 2 ..\o1_mf_1_2_58kw1xqx_.arc
3 695127443 4 ..\o1_mf_1_4_58kwb3wb_.arc
4 695127451 5 ..\o1_mf_1_5_58kwbck2_.arc
SQL>
As this shows, before this backup process we had two archived
redo log files. After backup, two more archived redo log files
have been created. Those resulted from the action where RMAN
archives the current online redo log files before and after
tablespace backup. If tablespace backup takes longer and
additional archived redo log files are created during backup, then
RMAN archives the current online redo log file and backs up all
archived redo log files created after tablespace backup.
Backup of archived redo logs can be limited according to the
scn number, time and the log sequence number. To get the scn,
sequence number and timestamp of the archived redo log file, query
the v$archived_log view. Then, using the from, until and between
commands with the scn, sequence and time clauses, the archived
redo log files can be backed up based on the requirements
selected. The use of these commands is shown in the following
example.
To back up the archived redo log file based on log sequence
number, use the following command:
RMAN> backup
archivelog sequence between 2 and 5;
Then, to get all archivelogs up to sequence number 5, use:
RMAN> backup
archivelog until sequence 5;
Next, to get archive log file with sequence number 3, use:
RMAN> backup
archivelog sequence 3;
Then to get all archive redo log files starting from sequence
number 6 until the end, use:
RMAN> backup
archivelog from sequence 6;
If the archived redo logs need to be backed up based on scn
number, use the same syntax as shown next:
RMAN> backup
archivelog from scn 552234;
The archived redo log file can be backed up based on the
timestamp of the first change in the file. To perform this
backup, use the TIME clause. In
this example, by getting a list of the archived redo log files, we
can back up all archived redo log files which have been accessed
during the previous hour:
SQL>
select
to_char(first_time,'ddmmyyyy hh24:mi:ss')
first_time,to_char(next_time,'ddmmyyyy hh24:mi:ss') next_time,
sequence#, stamp from v$archived_log;
FIRST_TIME NEXT_TIME
SEQUENCE# STAMP
----------------- ----------------- ---------- ----------
17082009 15:07:55 17082009 15:10:27 14
695142627
17082009 15:10:27 17082009 15:21:18 15
695143278
17082009 15:21:18 17082009 15:22:32 16
695143352
17082009 15:22:32 17082009 15:37:39 17
695144260
17082009 15:37:39 17082009 16:42:24 18
695148144
17082009 16:42:24 17082009 16:42:38 19
695148158
17082009 16:42:38 17082009 16:42:42 20
695148162
17082009 16:42:42 17082009 16:42:43 21
695148163
20 rows selected.
SQL>
RMAN> backup
archivelog from time 'sysdate-(1/24)';