Friday, January 20, 2017

Stepwise taking RMAN Full level 0 backup(Linux Server)

Step wise taking RMAN Full level 0 backup(Linux Server)

Step 1
---------
Create an rcv file on server.

vi rman_full_L0.rcv

Step 2
---------

Enter the following command in rcv file and save it (wq! used to save the file)

run {
allocate channel c1 type disk format='/RMAN/Full_BKP/Full_bkp_L0_%d_%s_%t_%U';
allocate channel c2 type disk format='/RMAN/Full_BKP/Full_bkp_L0_%d_%s_%t_%U';
allocate channel c3 type disk format='/RMAN/Full_BKP/Full_bkp_L0_%d_%s_%t_%U';
allocate channel c4 type disk format='/RMAN/Full_BKP/Full_bkp_L0_%d_%s_%t_%U';
backup as compressed backupset incremental level 0 database plus archivelog delete input;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete ;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
exit;

This run block will the full Rman L0 backup with archivelog and delete the achivelog,expired and obsolete backup  as well.

Step 3
---------
take the path where rcv file is created.

pwd (command is used for that)

Step 4
---------
Setup the env. and Run the rcv file from nohup

export ORACLE_SID=instance_name
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
export PATH=$PATH:/u01/app/oracle/product/11.2.0.4/dbhome_1/bin
DT=$(date +"%F")
nohup /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/rman target / cmdfile=/RMAN/scripts/rman_full_L0.rcv log=/RMAN/scripts/rman_full_L0_$DT.log &


Optional Step: (Schedule it in crontab)

Step 1
---------
Create a shell script like rman_full_l0.sh and put the following entry and save it

##for example I have create the sh script in /u01/app/oracle/scripts

vi rman_full_l0.sh

export ORACLE_SID=instance_name
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
export PATH=$PATH:/u01/app/oracle/product/11.2.0.4/dbhome_1/bin
DT=$(date +"%F")
nohup /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/rman target / cmdfile=/RMAN/scripts/rman_full_L0.rcv log=/RMAN/scripts/rman_full_L0_$DT.log &

step 2
----------
Invoke crontab editor

crontab -e and edit it like below

00 20 * * 0 sh /u01/app/oracle/scripts/RMAN_FULL_L0.sh >> /u01/app/oracle/scripts/RMAN_FULL_L0.log

This will allow the script to run on every sunday night at 8 PM server time zone

2 comments: