Backing Up Recovery Files

Em um cenário onde não seja adequado executar nossos backups diretamente em fita, temos a opção dentro do RMAN de realizar o backup da FRA ou dos recovery files que estão fora dela para outro diretório ou até mesmo em fita. Isso traz mais flexibilidade ao DBA, uma vez que algumas empresas já possuem um processo consagrado em relação as fitas, por exemplo delas serem levadas diariamente para fora do datacenter da origem, diminuindo assim a retenção de arquivos para eventual recuperação. Dependendo do evento, esperar que essas fitas sejam trazidas novamente para o seu datacenter pode custar caro para a empresa, caso um banco importante esteja precisando disso. Neste artigo mostraremos o exemplo da utilização desse recurso.

Realizando um backup do banco que será destinado à FRA:

[oracle@oel8 ~]$ rman target /
 
Recovery Manager: Release 18.0.0.0.0 - Production on Tue May 4 04:34:10 2021
Version 18.13.0.0.0
 
Copyright (c) 1982, 2018, Oracle and/or its affiliates.  All rights reserved.
 
connected to target database: RMANDB (DBID=3825250984)
 
RMAN> BACKUP DATABASE;
 
Starting backup at 2021-05-04:04:34:17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
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=/oracle/dados/RMANDB/datafile/o1_mf_system_h8nynqfx_.dbf
input datafile file number=00003 name=/oracle/dados/RMANDB/datafile/o1_mf_sysaux_h8nyq35q_.dbf
input datafile file number=00004 name=/oracle/dados/RMANDB/datafile/o1_mf_undotbs1_h8nyrjdr_.dbf
input datafile file number=00005 name=/oracle/dados/RMANDB/datafile/ts_cortex_catalog.dbf
input datafile file number=00007 name=/oracle/dados/RMANDB/datafile/o1_mf_users_h8nyrkn7_.dbf
channel ORA_DISK_1: starting piece 1 at 2021-05-04:04:34:18
channel ORA_DISK_1: finished piece 1 at 2021-05-04:04:36:13
piece handle=/oracle/fra/RMANDB/backupset/2021_05_04/o1_mf_nnndf_TAG20210504T043418_j91y7wvo_.bkp tag=TAG20210504T043418 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55
Finished backup at 2021-05-04:04:36:13
 
Starting Control File and SPFILE Autobackup at 2021-05-04:04:36:13
piece handle=/oracle/fra/RMANDB/autobackup/2021_05_04/o1_mf_s_1071635773_j91ycg6j_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2021-05-04:04:36:16
 
RMAN> LIST BACKUP OF DATABASE;
 
 
List of Backup Sets
===================
 
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
313     Full    1.29G      DISK        00:01:26     2021-05-04:04:35:44
        BP Key: 334   Status: AVAILABLE  Compressed: NO  Tag: TAG20210504T043418
        Piece Name: /oracle/fra/RMANDB/backupset/2021_05_04/o1_mf_nnndf_TAG20210504T043418_j91y7wvo_.bkp
  List of Datafiles in backup set 313
  File LV Type Ckp SCN    Ckp Time            Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- ------------------- ----------- ------ ----
  1       Full 2688140    2021-05-04:04:34:18              NO    /oracle/dados/RMANDB/datafile/o1_mf_system_h8nynqfx_.dbf
  3       Full 2688140    2021-05-04:04:34:18              NO    /oracle/dados/RMANDB/datafile/o1_mf_sysaux_h8nyq35q_.dbf
  4       Full 2688140    2021-05-04:04:34:18              NO    /oracle/dados/RMANDB/datafile/o1_mf_undotbs1_h8nyrjdr_.dbf
  5       Full 2688140    2021-05-04:04:34:18              NO    /oracle/dados/RMANDB/datafile/ts_cortex_catalog.dbf
  7       Full 2688140    2021-05-04:04:34:18              NO    /oracle/dados/RMANDB/datafile/o1_mf_users_h8nyrkn7_.dbf

Confirmando que o destino dos backups é a FRA configurada no banco de dados:

[oracle@oel8 ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 18.0.0.0.0 - Production on Tue May 4 04:37:36 2021
Version 18.13.0.0.0
 
Copyright (c) 1982, 2018, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.13.0.0.0
 
SQL> select instance_name,status from v$instance;
 
INSTANCE_NAME    STATUS
---------------- ------------
RMANDB           OPEN
 
SQL> SHOW PARAMETER RECOVERY;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      /oracle/fra
db_recovery_file_dest_size           big integer 5G
recovery_parallelism                 integer     0
remote_recovery_file_dest            string

Agora vamos realizar o backup dos archivelogs em um diretório fora da FRA:

RMAN> BACKUP ARCHIVELOG ALL FORMAT '/oracle/dados/RMANDB/BACKUP1/%U';
 
Starting backup at 2021-05-04:04:41:23
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=75 device type=DISK
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=68 RECID=75 STAMP=1069389781
input archived log thread=1 sequence=69 RECID=77 STAMP=1069390191
input archived log thread=1 sequence=70 RECID=78 STAMP=1069391841
input archived log thread=1 sequence=71 RECID=79 STAMP=1069392032
input archived log thread=1 sequence=72 RECID=80 STAMP=1069392053
input archived log thread=1 sequence=73 RECID=83 STAMP=1069392224
input archived log thread=1 sequence=74 RECID=84 STAMP=1069392226
input archived log thread=1 sequence=75 RECID=85 STAMP=1069430460
input archived log thread=1 sequence=76 RECID=86 STAMP=1069567218
input archived log thread=1 sequence=77 RECID=87 STAMP=1069581356
input archived log thread=1 sequence=78 RECID=88 STAMP=1070953640
input archived log thread=1 sequence=79 RECID=89 STAMP=1070992854
input archived log thread=1 sequence=80 RECID=90 STAMP=1071054025
input archived log thread=1 sequence=81 RECID=91 STAMP=1071075652
input archived log thread=1 sequence=82 RECID=92 STAMP=1071117108
input archived log thread=1 sequence=83 RECID=93 STAMP=1071140420
input archived log thread=1 sequence=84 RECID=94 STAMP=1071180017
input archived log thread=1 sequence=85 RECID=95 STAMP=1071190844
input archived log thread=1 sequence=86 RECID=96 STAMP=1071205211
input archived log thread=1 sequence=87 RECID=97 STAMP=1071205218
input archived log thread=1 sequence=88 RECID=98 STAMP=1071219611
input archived log thread=1 sequence=89 RECID=99 STAMP=1071376111
input archived log thread=1 sequence=90 RECID=100 STAMP=1071381640
input archived log thread=1 sequence=91 RECID=101 STAMP=1071396592
input archived log thread=1 sequence=92 RECID=102 STAMP=1071411059
input archived log thread=1 sequence=93 RECID=103 STAMP=1071552261
input archived log thread=1 sequence=94 RECID=104 STAMP=1071553535
input archived log thread=1 sequence=95 RECID=105 STAMP=1071553599
input archived log thread=1 sequence=96 RECID=106 STAMP=1071553824
input archived log thread=1 sequence=97 RECID=107 STAMP=1071554229
input archived log thread=1 sequence=98 RECID=108 STAMP=1071590436
input archived log thread=1 sequence=99 RECID=109 STAMP=1071636084
channel ORA_DISK_1: starting piece 1 at 2021-05-04:04:41:25
channel ORA_DISK_1: finished piece 1 at 2021-05-04:04:42:30
piece handle=/oracle/dados/RMANDB/BACKUP1/cavtvnjl_1_1 tag=TAG20210504T044124 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 2021-05-04:04:42:30
 
Starting Control File and SPFILE Autobackup at 2021-05-04:04:42:30
piece handle=/oracle/fra/RMANDB/autobackup/2021_05_04/o1_mf_s_1071636150_j91yq83r_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2021-05-04:04:42:33
 
RMAN> LIST BACKUP OF ARCHIVELOG ALL;
 
 
List of Backup Sets
===================
 
 
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
315     840.77M    DISK        00:00:16     2021-05-04:04:41:41
        BP Key: 336   Status: AVAILABLE  Compressed: NO  Tag: TAG20210504T044124
        Piece Name: /oracle/dados/RMANDB/BACKUP1/cavtvnjl_1_1
 
  List of Archived Logs in backup set 315
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    68      2255756    2021-03-28:10:39:58 2262113    2021-04-09:04:43:00
  1    69      2262113    2021-04-09:04:43:00 2262505    2021-04-09:04:49:50
  1    70      2262505    2021-04-09:04:49:50 2265296    2021-04-09:05:17:21
  1    71      2265296    2021-04-09:05:17:21 2265473    2021-04-09:05:20:32
  1    72      2265473    2021-04-09:05:20:32 2265531    2021-04-09:05:20:53
  1    73      2265531    2021-04-09:05:20:53 2265643    2021-04-09:05:23:29
  1    74      2265643    2021-04-09:05:23:29 2265663    2021-04-09:05:23:44
  1    75      2265663    2021-04-09:05:23:44 2290054    2021-04-09:16:01:00
  1    76      2290054    2021-04-09:16:01:00 2314554    2021-04-11:06:00:15
  1    77      2314554    2021-04-11:06:00:15 2328698    2021-04-11:09:55:53
  1    78      2328698    2021-04-11:09:55:53 2332924    2021-04-27:07:07:17
  1    79      2332924    2021-04-27:07:07:17 2358174    2021-04-27:18:00:52
  1    80      2358174    2021-04-27:18:00:52 2381091    2021-04-28:11:00:22
  1    81      2381091    2021-04-28:11:00:22 2394102    2021-04-28:17:00:49
  1    82      2394102    2021-04-28:17:00:49 2500292    2021-04-29:04:31:47
  1    83      2500292    2021-04-29:04:31:47 2519661    2021-04-29:11:00:18
  1    84      2519661    2021-04-29:11:00:18 2546021    2021-04-29:22:00:14
  1    85      2546021    2021-04-29:22:00:14 2559326    2021-04-30:01:00:41
  1    86      2559326    2021-04-30:01:00:41 2570072    2021-04-30:05:00:08
  1    87      2570072    2021-04-30:05:00:08 2570544    2021-04-30:05:00:15
  1    88      2570544    2021-04-30:05:00:15 2580734    2021-04-30:09:00:09
  1    89      2580734    2021-04-30:09:00:09 2607950    2021-05-01:04:28:27
  1    90      2607950    2021-05-01:04:28:27 2620519    2021-05-01:06:00:37
  1    91      2620519    2021-05-01:06:00:37 2634806    2021-05-01:10:09:50
  1    92      2634806    2021-05-01:10:09:50 2648651    2021-05-01:14:10:57
  1    93      2648651    2021-05-01:14:10:57 2655511    2021-05-03:05:24:19
  1    94      2655511    2021-05-03:05:24:19 2656517    2021-05-03:05:45:34
  1    95      2656517    2021-05-03:05:45:34 2656617    2021-05-03:05:46:39
  1    96      2656617    2021-05-03:05:46:39 2656827    2021-05-03:05:50:24
  1    97      2656827    2021-05-03:05:50:24 2657118    2021-05-03:05:57:09
  1    98      2657118    2021-05-03:05:57:09 2679421    2021-05-03:16:00:34
  1    99      2679421    2021-05-03:16:00:34 2688357    2021-05-04:04:41:23

Simulando o backup da FRA para um diretório diferente. Neste caso, apenas o backup do banco de dados é contemplado:

RMAN> BACKUP RECOVERY AREA TO DESTINATION '/oracle/dados/RMANDB/BACKUP2';
 
Starting backup at 2021-05-04:04:45:44
using channel ORA_DISK_1
specification does not match any datafile copy in the repository
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=69 RECID=77 STAMP=1069390191
channel ORA_DISK_1: starting piece 1 at 2021-05-04:04:45:44
channel ORA_DISK_1: finished piece 1 at 2021-05-04:04:45:45
piece handle=/oracle/dados/RMANDB/BACKUP2/RMANDB/backupset/2021_05_04/o1_mf_annnn_TAG20210504T044544_j91yx8h9_.bkp tag=TAG20210504T044544 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: input backup set: count=392, stamp=1071635658, piece=1
channel ORA_DISK_1: starting piece 1 at 2021-05-04:04:45:45
channel ORA_DISK_1: backup piece /oracle/fra/RMANDB/backupset/2021_05_04/o1_mf_nnndf_TAG20210504T043418_j91y7wvo_.bkp
piece handle=/oracle/dados/RMANDB/BACKUP2/RMANDB/backupset/2021_05_04/o1_mf_nnnnf__j91yx9kj_.bkp comment=NONE
channel ORA_DISK_1: finished piece 1 at 2021-05-04:04:47:20
channel ORA_DISK_1: backup piece complete, elapsed time: 00:01:35
channel ORA_DISK_1: input backup set: count=393, stamp=1071635773, piece=1
channel ORA_DISK_1: starting piece 1 at 2021-05-04:04:47:20
channel ORA_DISK_1: backup piece /oracle/fra/RMANDB/autobackup/2021_05_04/o1_mf_s_1071635773_j91ycg6j_.bkp
piece handle=/oracle/dados/RMANDB/BACKUP2/RMANDB/backupset/2021_05_04/o1_mf_nnnnf__j91z08nb_.bkp comment=NONE
channel ORA_DISK_1: finished piece 1 at 2021-05-04:04:47:21
channel ORA_DISK_1: backup piece complete, elapsed time: 00:00:01
channel ORA_DISK_1: input backup set: count=395, stamp=1071636150, piece=1
channel ORA_DISK_1: starting piece 1 at 2021-05-04:04:47:21
channel ORA_DISK_1: backup piece /oracle/fra/RMANDB/autobackup/2021_05_04/o1_mf_s_1071636150_j91yq83r_.bkp
piece handle=/oracle/dados/RMANDB/BACKUP2/RMANDB/backupset/2021_05_04/o1_mf_nnnnf__j91z09ol_.bkp comment=NONE
channel ORA_DISK_1: finished piece 1 at 2021-05-04:04:47:22
channel ORA_DISK_1: backup piece complete, elapsed time: 00:00:01
Finished backup at 2021-05-04:04:47:22
 
Starting Control File and SPFILE Autobackup at 2021-05-04:04:47:22
piece handle=/oracle/fra/RMANDB/autobackup/2021_05_04/o1_mf_s_1071636442_j91z0ckc_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2021-05-04:04:47:25

Também podemos realizar o backup dos arquivos que estão fora da FRA, que no nosso caso foram os archivelog, vide exemplo abaixo:

[oracle@oel8 2021_05_04]$ rman target /
 
Recovery Manager: Release 18.0.0.0.0 - Production on Tue May 4 04:52:07 2021
Version 18.13.0.0.0
 
Copyright (c) 1982, 2018, Oracle and/or its affiliates.  All rights reserved.
 
connected to target database: RMANDB (DBID=3825250984)
 
RMAN> BACKUP RECOVERY FILES TO DESTINATION '/oracle/dados/RMANDB/BACKUP2';
 
Starting backup at 2021-05-04:04:52:12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=97 device type=DISK
specification does not match any datafile copy in the repository
skipping archived log of thread 1 with sequence 69; already backed up
skipping archived log of thread 1 with sequence 69; already backed up
skipping backup set key 313; already backed up 1 time(s)
skipping backup set key 314; already backed up 1 time(s)
skipping backup set key 316; already backed up 1 time(s)
skipping backup set key 317; already backed up 1 time(s)
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=68 RECID=75 STAMP=1069389781
input archived log thread=1 sequence=70 RECID=78 STAMP=1069391841
input archived log thread=1 sequence=71 RECID=79 STAMP=1069392032
input archived log thread=1 sequence=72 RECID=80 STAMP=1069392053
input archived log thread=1 sequence=73 RECID=83 STAMP=1069392224
input archived log thread=1 sequence=74 RECID=84 STAMP=1069392226
input archived log thread=1 sequence=75 RECID=85 STAMP=1069430460
input archived log thread=1 sequence=76 RECID=86 STAMP=1069567218
input archived log thread=1 sequence=77 RECID=87 STAMP=1069581356
input archived log thread=1 sequence=78 RECID=88 STAMP=1070953640
input archived log thread=1 sequence=79 RECID=89 STAMP=1070992854
input archived log thread=1 sequence=80 RECID=90 STAMP=1071054025
input archived log thread=1 sequence=81 RECID=91 STAMP=1071075652
input archived log thread=1 sequence=82 RECID=92 STAMP=1071117108
input archived log thread=1 sequence=83 RECID=93 STAMP=1071140420
input archived log thread=1 sequence=84 RECID=94 STAMP=1071180017
input archived log thread=1 sequence=85 RECID=95 STAMP=1071190844
input archived log thread=1 sequence=86 RECID=96 STAMP=1071205211
input archived log thread=1 sequence=87 RECID=97 STAMP=1071205218
input archived log thread=1 sequence=88 RECID=98 STAMP=1071219611
input archived log thread=1 sequence=89 RECID=99 STAMP=1071376111
input archived log thread=1 sequence=90 RECID=100 STAMP=1071381640
input archived log thread=1 sequence=91 RECID=101 STAMP=1071396592
input archived log thread=1 sequence=92 RECID=102 STAMP=1071411059
input archived log thread=1 sequence=93 RECID=103 STAMP=1071552261
input archived log thread=1 sequence=94 RECID=104 STAMP=1071553535
input archived log thread=1 sequence=95 RECID=105 STAMP=1071553599
input archived log thread=1 sequence=96 RECID=106 STAMP=1071553824
input archived log thread=1 sequence=97 RECID=107 STAMP=1071554229
input archived log thread=1 sequence=98 RECID=108 STAMP=1071590436
input archived log thread=1 sequence=99 RECID=109 STAMP=1071636084
channel ORA_DISK_1: starting piece 1 at 2021-05-04:04:52:12
channel ORA_DISK_1: finished piece 1 at 2021-05-04:04:52:57
piece handle=/oracle/dados/RMANDB/BACKUP2/RMANDB/backupset/2021_05_04/o1_mf_annnn_TAG20210504T045212_j91z9dxz_.bkp tag=TAG20210504T045212 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: input backup set: count=394, stamp=1071636085, piece=1
channel ORA_DISK_1: starting piece 1 at 2021-05-04:04:52:57
channel ORA_DISK_1: backup piece /oracle/dados/RMANDB/BACKUP1/cavtvnjl_1_1
piece handle=/oracle/dados/RMANDB/BACKUP2/RMANDB/backupset/2021_05_04/o1_mf_nnnnf__j91zbt25_.bkp comment=NONE
channel ORA_DISK_1: finished piece 1 at 2021-05-04:04:53:43
channel ORA_DISK_1: backup piece complete, elapsed time: 00:00:46
channel ORA_DISK_1: input backup set: count=404, stamp=1071636442, piece=1
channel ORA_DISK_1: starting piece 1 at 2021-05-04:04:53:43
channel ORA_DISK_1: backup piece /oracle/fra/RMANDB/autobackup/2021_05_04/o1_mf_s_1071636442_j91z0ckc_.bkp
piece handle=/oracle/dados/RMANDB/BACKUP2/RMANDB/backupset/2021_05_04/o1_mf_nnnnf__j91zd775_.bkp comment=NONE
channel ORA_DISK_1: finished piece 1 at 2021-05-04:04:53:44
channel ORA_DISK_1: backup piece complete, elapsed time: 00:00:01
Finished backup at 2021-05-04:04:53:44
 
Starting Control File and SPFILE Autobackup at 2021-05-04:04:53:44
piece handle=/oracle/fra/RMANDB/autobackup/2021_05_04/o1_mf_s_1071636824_j91zd933_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2021-05-04:04:53:47

Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laboratório pessoal para fins de aprendizado.

Leave a Comment

Your email address will not be published.