Outro recurso para obtermos informações relacionadas com o RMAN, é usando o comando REPORT. No exemplo abaixo, podemos checar também as característica do banco de dados, como os datafiles que o compõem, as tablespaces atribuídas, o tamanho, etc:
[oracle@oel8 ~]$ rman target /
Recovery Manager: Release 18.0.0.0.0 - Production on Fri Apr 9 20:08:13 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> REPORT SCHEMA;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name RMANDB
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 860 SYSTEM YES /oracle/dados/RMANDB/datafile/o1_mf_system_h8nynqfx_.dbf
3 630 SYSAUX NO /oracle/dados/RMANDB/datafile/o1_mf_sysaux_h8nyq35q_.dbf
4 305 UNDOTBS1 YES /oracle/dados/RMANDB/datafile/o1_mf_undotbs1_h8nyrjdr_.dbf
5 200 TS_CORTEX_CATALOG NO /oracle/dados/RMANDB/datafile/ts_cortex_catalog.dbf
7 5 USERS NO /oracle/dados/RMANDB/datafile/o1_mf_users_h8nyrkn7_.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 32 TEMP 32767 /oracle/dados/RMANDB/datafile/o1_mf_temp_h8nyvt1f_.tmp
RMAN>
Também temos algumas opções do comando report schema, como utilizar os parâmetros de data, SCN, Sequence e DB_UNIQUE_NAME, conforme exemplos abaixo. Porém, como nosso ambiente ainda não possui um catálogo configurado, os comandos reportam erro. Os coloquei aqui como menção de existência, mas em artigos posteriores, os mostrarei funcionando junto ao catálogo:
RMAN> REPORT SCHEMA AT TIME 'SYSDATE-1';
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of report command at 04/09/2021 20:19:06
RMAN-06137: must have recovery catalog for REPORT SCHEMA AT TIME
RMAN> REPORT SCHEMA AT SCN 100;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of report command at 04/09/2021 20:19:19
RMAN-06137: must have recovery catalog for REPORT SCHEMA AT TIME
RMAN> REPORT SCHEMA AT SEQUENCE 100 THREAD 1;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of report command at 04/09/2021 20:19:25
RMAN-06137: must have recovery catalog for REPORT SCHEMA AT TIME
RMAN> REPORT SCHEMA FOR DB_UNIQUE_NAME RMANDB;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of report command at 04/09/2021 20:19:31
RMAN-05037: FOR DB_UNIQUE_NAME option cannot be used in nocatalog mode
Vamos criar uma tablespace nova para simular algumas situações:
RMAN> SQL 'CREATE TABLESPACE BSS';
sql statement: CREATE TABLESPACE BSS
O comando a seguir nos indica os conteúdos que ainda não foram contemplados com o backup, exibindo desse modo o datafile criado acima (resultado da criação da tablespace):
RMAN> REPORT NEED BACKUP;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
2 0 /oracle/dados/RMANDB/datafile/o1_mf_bss_j71qto1x_.dbf
Também podemos usar este comando com outros parâmetros, como o device type, por tablespace, redundância, e até realizando o skip de tablespace:
RMAN> SHOW RETENTION POLICY;
RMAN configuration parameters for database with db_unique_name RMANDB are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
RMAN> REPORT NEED BACKUP REDUNDANCY 1 DATABASE SKIP TABLESPACE BSS;
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
RMAN> REPORT NEED BACKUP REDUNDANCY 2 DATABASE SKIP TABLESPACE BSS;
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
RMAN> REPORT NEED BACKUP REDUNDANCY 2 DATABASE SKIP TABLESPACE USERS;
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
2 0 /oracle/dados/RMANDB/datafile/o1_mf_bss_j71qto1x_.dbf
RMAN> REPORT NEED BACKUP REDUNDANCY 1 DATAFILE 2;
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
2 0 /oracle/dados/RMANDB/datafile/o1_mf_bss_j71qto1x_.dbf
RMAN> REPORT NEED BACKUP DEVICE TYPE DISK;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
2 0 /oracle/dados/RMANDB/datafile/o1_mf_bss_j71qto1x_.dbf
RMAN> REPORT NEED BACKUP REDUNDANCY 1 DEVICE TYPE DISK;
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
2 0 /oracle/dados/RMANDB/datafile/o1_mf_bss_j71qto1x_.dbf
RMAN> REPORT NEED BACKUP TABLESPACE USERS DEVICE TYPE SBT;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
7 0 /oracle/dados/RMANDB/datafile/o1_mf_users_h8nyrkn7_.dbf
Realizando o backup da tablespace BSS:
RMAN> BACKUP TABLESPACE BSS;
Starting backup at 2021-04-09:20:41:04
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=68 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=00002 name=/oracle/dados/RMANDB/datafile/o1_mf_bss_j71qto1x_.dbf
channel ORA_DISK_1: starting piece 1 at 2021-04-09:20:41:05
channel ORA_DISK_1: finished piece 1 at 2021-04-09:20:41:06
piece handle=/oracle/fra/RMANDB/backupset/2021_04_09/o1_mf_nnndf_TAG20210409T204104_j71sjk5l_.bkp tag=TAG20210409T204104 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2021-04-09:20:41:06
Starting Control File and SPFILE Autobackup at 2021-04-09:20:41:06
piece handle=/oracle/fra/RMANDB/autobackup/2021_04_09/o1_mf_s_1069447266_j71sjlrt_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2021-04-09:20:41:09
Como a nossa retenção está em 2 backups, o datafile ainda é reportado no comando abaixo:
RMAN> REPORT NEED BACKUP;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
2 1 /oracle/dados/RMANDB/datafile/o1_mf_bss_j71qto1x_.dbf
Realizando outro backup da mesma tablespace:
RMAN> BACKUP TABLESPACE BSS;
Starting backup at 2021-04-09:20:45:44
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/oracle/dados/RMANDB/datafile/o1_mf_bss_j71qto1x_.dbf
channel ORA_DISK_1: starting piece 1 at 2021-04-09:20:45:44
channel ORA_DISK_1: finished piece 1 at 2021-04-09:20:45:45
piece handle=/oracle/fra/RMANDB/backupset/2021_04_09/o1_mf_nnndf_TAG20210409T204544_j71ss8jf_.bkp tag=TAG20210409T204544 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2021-04-09:20:45:45
Starting Control File and SPFILE Autobackup at 2021-04-09:20:45:45
piece handle=/oracle/fra/RMANDB/autobackup/2021_04_09/o1_mf_s_1069447545_j71ssb5n_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2021-04-09:20:45:48
Nenhum datafile é reportado dessa vez:
RMAN> REPORT NEED BACKUP;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
Se mudarmos o valor de retenção em tempo de execução para 3, o datafile é reportado novamente:
RMAN> REPORT NEED BACKUP REDUNDANCY 3 DATAFILE 2;
Report of files with less than 3 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
2 2 /oracle/dados/RMANDB/datafile/o1_mf_bss_j71qto1x_.dbf
Removendo tablespace:
RMAN> SQL 'DROP TABLESPACE BSS INCLUDING CONTENTS AND DATAFILES';
sql statement: DROP TABLESPACE BSS INCLUDING CONTENTS AND DATAFILES
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.