Catalog Creation and Different Types of Backup

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 7

=============================================================================

Catalog Creation and full backup

==============================================================================

sqlplus / as sysdba

archive log list;

---if no archivelog mode----

shutdown immediate

startup mount

alter database archivelog;

alter database open;

select file_name from dba_data_files;

create tablespace tsrman


datafile '/u01/app/oracle/oradata/ORCL/datafile/tsrman01.dbf'
size 512M
extent management local
segment space management auto;

create user rmancat


identified by rmancat
default tablespace tsrman
temporary tablespace temp
quota unlimited on tsrman;

grant recovery_catalog_owner to rmancat;

rman target /

vi tnsnames.ora
cat tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/netw


ork/admin/tnsnames.ora
# Generated by Oracle configuration tools.

PDBTS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdbts.localdomain)
)
)

ORCLPDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpdb.localdomain)
)
)

LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle.localdomain)(PORT = 1521))

ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.localdomain)
)
)

vi tnsnames.ora
cat tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/netw


ork/admin/tnsnames.ora
# Generated by Oracle configuration tools.

PDBTS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdbts.localdomain)
)
)

ORCLPDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpdb.localdomain)
)
)

LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle.localdomain)(PORT = 1521))

ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.localdomain)
)
)
CATDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.localdomain)
)
)

rman catalog rmancat/rmancat@catdb

create catalog;

rman target / catalog rmancat/rmancat@catdb

register database;

create global script hot_bk


{ backup database;
}

list global script names;

print global script hot_bk;

report schema;

report obsolete;

report unrecoverable;

show all;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO


'/u01/app/oracle/rman_bkp/%F';

run {
allocate channel c1 type disk;
backup as backupset format '/u01/app/oracle/rman_bkp/df_%d_%s_%p'
incremental level 0 database;
backup as backupset format '/u01/app/oracle/rman_bkp/ar_%d_%s_%p'
archivelog all delete input;
}

report need backup;

list backup of database;

list backup of controlfile;


list backup of archivelog all;

sqlplus / as sysdba

conn hr/hr

create table test (id number, name varchar2(50));

insert into test values(1,'Raihan');

rman target / catalog rmancat/rmancat@catdb

run {
allocate channel c1 type disk;
backup as backupset format '/u01/app/oracle/rman_bkp/df_%d_%s_%p'
incremental level 1 cumulative database;
backup as backupset format '/u01/app/oracle/rman_bkp/ar_%d_%s_%p'
archivelog all delete input; <--------means first take archivelog backup and
delete old archivelog backup
}

cd /u02/rman_bkp/

======================Enable Block Change


Tracking=======================================

sqlplus / as sysdba

alter database enable block change tracking using file


'/u01/app/oracle/rman_bkp/block_change.f';
cd /u01/app/oracle/rman_bkp/

rman target / catalog rmancat/rmancat@catdb

incremental backup:
---------------------

run {
allocate channel c1 type disk;
backup as backupset format '/u01/app/oracle/rman_bkp/df_%d_%s_%p'
incremental level 1 database;
}

cd /u01/rman_bkp/

[oracle@oracle rman_bkp]$ du -sm df_ORCL_1_1 <---------check backup file size

cd /u01/rman_bkp/
rman target / catalog rmancat/rmancat@catdb

full compress backup:


----------------------
run {
2> allocate channel c1 type disk;
3> backup as compressed backupset format '/u01/app/oracle/rman_bkp/df_%d_%s_%p'
4> incremental level 0 database;
5> }

[oracle@oracle rman_bkp]$ du -sm df_ORCL_11_1 <<----------file size before


compression backup enable
316 df_ORCL_11_1

[oracle@oracle rman_bkp]$ du -sm df_ORCL_9_1 <<----------file size after


compression backup enable
3 df_ORCL_9_1

Practice by Removing Backup


----------------------------------------------------

cd /u02/rman_bkp

[oracle@oracle rman_bkp]$ rm -rf c-1579011246-20201008-04 df_ORCL_1_1 df_ORCL_11_1

-----Note before going to take backup first solve proble deleted files so blow step
show be necessary

rman target / catalog rmancat/rmancat@catdb

crosscheck backup;

allocated channel: ORA_DISK_1


channel ORA_DISK_1: SID=63 device type=DISK
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/app/oracle/rman_bkp/df_ORCL_1_1 RECID=1 STAMP=1053260865
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/ar_ORCL_2_1 RECID=2 STAMP=1053260995
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/c-1579011246-20201008-00 RECID=3
STAMP=1053261008
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/df_ORCL_4_1 RECID=4 STAMP=1053262085
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/ar_ORCL_5_1 RECID=5 STAMP=1053262129
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/c-1579011246-20201008-01 RECID=6
STAMP=1053262134
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/df_ORCL_7_1 RECID=7 STAMP=1053262793
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/c-1579011246-20201008-02 RECID=8
STAMP=1053262831
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/df_ORCL_9_1 RECID=9 STAMP=1053264361
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/c-1579011246-20201008-03 RECID=10
STAMP=1053264366
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/app/oracle/rman_bkp/df_ORCL_11_1 RECID=11 STAMP=1053264995
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/app/oracle/rman_bkp/c-1579011246-20201008-04 RECID=12
STAMP=1053265114
Crosschecked 12 objects

delete expired backup;

crosscheck backup;

using channel ORA_DISK_1


crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/ar_ORCL_2_1 RECID=2 STAMP=1053260995
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/c-1579011246-20201008-00 RECID=3
STAMP=1053261008
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/df_ORCL_4_1 RECID=4 STAMP=1053262085
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/ar_ORCL_5_1 RECID=5 STAMP=1053262129
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/c-1579011246-20201008-01 RECID=6
STAMP=1053262134
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/df_ORCL_7_1 RECID=7 STAMP=1053262793
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/c-1579011246-20201008-02 RECID=8
STAMP=1053262831
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/df_ORCL_9_1 RECID=9 STAMP=1053264361
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/rman_bkp/c-1579011246-20201008-03 RECID=10
STAMP=1053264366

Crosschecked 9 objects <-------now no backup EXPIRED AVAILABLE PROBLEM SOLVED

-------------If any backup want to keep forever or long time must media recovery
active then do below---

list backup;

change backup tag 'TAG20201008T132605' keep forever;

list backup of controlfile;

list backup of database;


list backup;

-------------If do not want forever or long time must media recovery active then do
below---

change backup tag 'TAG20201008T132605' nokeep;

list backup of controlfile;

You might also like