Wednesday, August 9, 2017

Datapump Backup Status

select
   round(sofar/totalwork*100,2)  percent_completed,
   v$session_longops.*
from
   v$session_longops
where
   sofar <> totalwork
order by
   target,
   sid;

RMAN Backup Restore

1. pfile create
2. startup nomount with pfile
3. restore control file (backup control file)
4. shutdown immediate
5. Again in Pfile, changes control file location/name according to restore control file
6. Startup nomount with pfile
7. alter datbase mount
8. restore database preview; (pickup scn for restore this point)
9. restore and recover datbase;    

**Note: when restore level 0 and Level 1 backup. For control file restoring, restore latest level 1 control file of that backup.

===========PFILE======
*.audit_file_dest='/u02/app/oracle/admin/dcpdb/adump'
*.audit_sys_operations=TRUE
*.audit_trail='DB','EXTENDED'
*.compatible='11.2.0.4.0'
*.control_files='+REDO/dcpdb/controlfile/current.256.951579285','+CONTROL/dcpdb/controlfile/current.256.951579285'
*.cursor_sharing='EXACT'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_create_online_log_dest_1='+REDO'
*.db_create_online_log_dest_2='+CONTROL'
*.db_domain='nblitd.com'
*.db_name='dcpdb'
*.db_recovery_file_dest='+FRA'
*.db_recovery_file_dest_size=448256040960
*.db_unique_name='dcpdb'
*.dg_broker_start=FALSE
*.diagnostic_dest='/u02/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=dcpdbXDB)'
*.filesystemio_options='SETALL'
#*.local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dcpdb1-vip.nblitd.com)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=dcpdb1-vip.nblitd.com)(PORT=1971))))'
#*.log_archive_config='DG_CONFIG=(dcpdb,drpdb)'
#*.log_archive_dest_1='LOCATION=DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=dcpdb'
*.log_archive_dest_1='LOCATION=+fra/dcpdb/ARCHIVELOG'
#*.log_archive_dest_state_1='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=10
#*.memory_target=82678120448
*.memory_target=4294967296
*.open_cursors=5000
*.optimizer_index_cost_adj=100
*.processes=5000
*.query_rewrite_integrity='TRUSTED'
*.remote_login_passwordfile='exclusive'
*.session_cached_cursors=5000
*.sessions=7524
*.undo_retention=10800
*.undo_tablespace='UNDOTBS1'


--====01_control_restore.sh===Restore control file script===
#!/bin/sh

export ORACLE_BASE=/u02/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4.0/dbhome_1
export ORACLE_SID=dcpdb
export PATH=$ORACLE_HOME/bin:$PATH
LOG_FILE=/db_rmanbackup/rman_Restore_controlfile_${ORACLE_SID}_`date +%y%m%d%H%M`.log
echo "dcpdb Controlfile Restore STARTED on `date` " >$LOG_FILE
rman target /  <<! >>$LOG_FILE
run {
restore controlfile from '/db_rmanbackup/t24_ctl_l1_1_6682_060820170800.bkp';
}
!
echo "dcpdb Controlfile Restore FINISHIED on  `date` " >>$LOG_FILE

exit 0

--=====02_restore_db.sh=====Restore and recover database script===
#!/bin/sh
export ORACLE_BASE=/u02/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4.0/dbhome_1
export ORACLE_SID=dcpdb
export PATH=$ORACLE_HOME/bin:$PATH
LOG_FILE=/db_rmanbackup/rman_${ORACLE_SID}_Restore_`date +%y%m%d%H%M`.log
echo "dcpdb database Restore STARTED on `date` " >$LOG_FILE
rman target /  <<! >>$LOG_FILE
run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
SET UNTIL SCN 35660797287;
RESTORE DATABASE;
RECOVER DATABASE;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
!
echo "dcpdb database Restore FINISHIED on  `date` " >>$LOG_FILE

exit 0


--====03_recover_db.sh====recover database (standalone)===
#!/bin/sh
export ORACLE_BASE=/u02/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4.0/dbhome_1
export ORACLE_SID=dcpdb
export PATH=$ORACLE_HOME/bin:$PATH
LOG_FILE=/db_rmanbackup/rman_${ORACLE_SID}_Recover_`date +%y%m%d%H%M`.log
echo "dcpdb database Recover STARTED on `date` " >$LOG_FILE
rman target /  <<! >>$LOG_FILE
run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
SET UNTIL SCN 33986365999;
RECOVER DATABASE;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
!
echo "dcpdb database Reccover  FINISHIED on  `date` " >>$LOG_FILE

exit 0


--=====run script command===
oracle@drp4db [/db_rmanbackup]$ nohup 01_control_restore.sh &
oracle@drp4db [/db_rmanbackup]$ nohup 02_restore_db.sh &