Tuesday, 8 January 2019

RMAN Image Full Backup copy and Restore

--Backup script which we have used

server_1:TESTDB:/RMAN/TESTDB/image_copy $cat IMAG_BACKUP_TESTDB.sh
rman cmdfile=/rman/oracle/backups/TESTDB/image_copy/IMAG_BACKUP_TESTDB.rcv log=/rman/oracle/backups/TESTDB/image_copy/IMAG_BACKUP_TESTDB.log
server_1:TESTDB:/RMAN/TESTDB/image_copy $cat IMAG_BACKUP_TESTDB.rcv

connect target /y
RUN
{
 ALLOCATE CHANNEL c1 TYPE DISK FORMAT '/rman/oracle/backups/TESTDB/image_copy/backups_image_copy_TSMPRD_%U';
 ALLOCATE CHANNEL c2 TYPE DISK FORMAT '/rman/oracle/backups/TESTDB/image_copy/backups_image_copy_TSMPRD_%U';
 ALLOCATE CHANNEL c3 TYPE DISK FORMAT '/rman/oracle/backups/TESTDB/image_copy/backups_image_copy_TSMPRD_%U';
 ALLOCATE CHANNEL c4 TYPE DISK FORMAT '/rman/oracle/backups/TESTDB/image_copy/backups_image_copy_TSMPRD_%U';
 BACKUP AS COPY DATABASE;
 RELEASE CHANNEL c1;
 RELEASE CHANNEL c2;
 RELEASE CHANNEL c3;
 RELEASE CHANNEL c4;
}

Backup location

server_1:TESTDB:/RMAN/TESTDB/image_copy $


--------Restoration steps---------

export ORACLE_SID=TESTDB
export ORACLE_HOME=/oracle/product/10.2.0.4
export PATH=$ORACLE_HOME/bin:$PATH
sqlplus

start TESTDB database if not started and take backup of parameter file/spfile and drop database on server_1
1)
to drop database

start database in restrict mode
a) startup restrict
b) show parameter db_name
c) drop database

2) check control file backup as below  and transfer to server_1

server_prod:tatprd:/export/home/oracle $
server_prod:tatprd:/export/home/oracle $. oraenv
ORACLE_SID = [tatprd] ? TESTDB
server_prod:TESTDB:/export/home/oracle $rman

Recovery Manager: Release 10.2.0.4.0 - Production on Wed Dec 19 15:44:08 2018

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

RMAN> connect target

connected to target database: TESTDB (DBID=296424721)

RMAN> show all
2> ;

using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/rman/oracle/backups/TESTDB/controlfile/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/distprod1/product/10.2.0.4/dbs/snapcf_TESTDB.f'; # default

RMAN>

cd /rman/oracle/backups/TESTDB/controlfile/%F'
ls -ltr

copy control file on server_1 server




2) startup nomount using backup spfile

3)  restore a controlfile

connect target /

 run
{

allocate channel c1 device type disk;
allocate channel c2 device type disk;
RESTORE CONTROLFILE FROM AUTOBACKUP;
release channel ch1;
release channel ch1;

or

and give control file location

connect target /

 run
{

allocate channel c1 device type disk;
allocate channel c2 device type disk;
RESTORE CONTROLFILE FROM '/RMAN/TESTDB/image_copy/controlfile/c-296424721-20181216-00';
release channel ch1;
release channel ch1;



3)  catalog the backup:

RMAN>  catalog start with '/RMAN/TESTDB/image_copy

list datafilecopy all; it is for image copy


4) prepare scrip and run in no hub


server_1:TESTDB:/RMAN/TESTDB/image_copy/controlfile $cat image_restore.sh
rman cmdfile=/RMAN/TESTDB/image_copy/image_restore.rcv log=/RMAN/TESTDB/image_copy/image_restore.log
server_1:TESTDB:/RMAN/TESTDB/image_copy/controlfile $cat image_restore.rcv
connect target /
RUN
{
 ALLOCATE CHANNEL c1 TYPE DISK ;
 ALLOCATE CHANNEL c2 TYPE DISK ;
 ALLOCATE CHANNEL c3 TYPE DISK ;
 ALLOCATE CHANNEL c4 TYPE DISK ;
 restore database;
 RELEASE CHANNEL c1;
 RELEASE CHANNEL c2;
 RELEASE CHANNEL c3;
 RELEASE CHANNEL c4;
}

server_1:TESTDB:/RMAN/TESTDB/image_copy/controlfile $


nohup image_restore.sh &


monitor log alert log


/ora/tms01prd/trace/oradata/tms01prd/bdump $
tail - 200f alert.log

Database will be started in mount stage

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- ----------
TESTDB    MOUNTED

SQL>

Please check  all datafiles online and read write
and all tempfiles online and read write

SQL> set lines 140 pages 50
col name format A70
select file#, name, status, enabled from v$datafile;SQL> SQL>


select * from v$tempfile;

run db verify on mount stage of database

set head off
set linesize 200
select 'dbv file=' || name  from v$datafile;



server_1:TESTDB:/RMAN/TESTDB/image_copy $chmod 775 dbverify_tsmprd.sh
server_1:TESTDB:/RMAN/TESTDB/image_copy $

nohup dbverify_tsmprd.sh&

validate database as below

 run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup validate check logical database;
 RELEASE CHANNEL c1;
 RELEASE CHANNEL c2;
 RELEASE CHANNEL c3;
 RELEASE CHANNEL c4;
}


SQL> set linesize 200
SQL> select * from v$database_block_corruption;

no rows selected

SQL> select name from v$database
  2  ;

NAME
---------
TESTDB

SQL> D

SQL> !date
Thu Dec 20 15:29:49 GMT 2018

SQL>


=================TESTDB copy command===================

-rw-r-----   1 eibm994  dba      4269809664 Dec 16 08:28 backups_image_copy_TSMPRD_data_D-TESTDB_I-296424721_TS-TSPACED03_FNO-336_9stksq7g
server_1:TESTDB:/RMAN/TESTDB/image_copy $cat IMAG_BACKUP_TESTDB.sh
rman cmdfile=/rman/oracle/backups/TESTDB/image_copy/IMAG_BACKUP_TESTDB.rcv log=/rman/oracle/backups/TESTDB/image_copy/IMAG_BACKUP_TESTDB.log
server_1:TESTDB:/RMAN/TESTDB/image_copy $cat IMAG_BACKUP_TESTDB.rcv

connect target /
RUN
{
 ALLOCATE CHANNEL c1 TYPE DISK FORMAT '/rman/oracle/backups/TESTDB/image_copy/backups_image_copy_TSMPRD_%U';
 ALLOCATE CHANNEL c2 TYPE DISK FORMAT '/rman/oracle/backups/TESTDB/image_copy/backups_image_copy_TSMPRD_%U';
 ALLOCATE CHANNEL c3 TYPE DISK FORMAT '/rman/oracle/backups/TESTDB/image_copy/backups_image_copy_TSMPRD_%U';
 ALLOCATE CHANNEL c4 TYPE DISK FORMAT '/rman/oracle/backups/TESTDB/image_copy/backups_image_copy_TSMPRD_%U';
 BACKUP AS COPY DATABASE;
 RELEASE CHANNEL c1;
 RELEASE CHANNEL c2;
 RELEASE CHANNEL c3;
 RELEASE CHANNEL c4;
}

server_1:TESTDB:/RMAN/TESTDB/image_copy $












Enter user-name: / as sysdba

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select sum(bytes)/1024/1024/1024 "Total DB size in GB"  from dba_data_files;

Total DB size in GB
-------------------
         1911.25967

SQL> select sum(bytes/1024/1024/1024) tbspc_gb from dba_temp_files;

  TBSPC_GB
----------
53.7269287

SQL> select count(1) from dba_data_files;

  COUNT(1)
----------
       468

SQL> select sum(bytes)/1024/1024/1024 "Total DB size in GB" from dba_segments;

Total DB size in GB
-------------------
         1250.34795

SQL>

No comments:

Post a Comment