RMAN Full Backup

Share via:

/u01/app/oracle/DBA/rmanbackup.sh

#!/bin/ksh
CURRDATETIME=date '+%Y%m%d-%H%M%S'a
ORACLE_SID=ORCL1;export ORACLE_SID
ORACLE_HOME=/u01/app/oracle/product/12.1.0.2;export ORACLE_HOME
LOGDIR=/var/opt/oracle/logs
LOGFILE=${LOGDIR}/${ORACLE_SID}_rman_${CURRDATETIME}.log

RMANBACKUPDIR=/backup/ORCL1/jul16

$ORACLE_HOME/bin/sqlplus dbsnmp/password <<EOF | tee -a $LOGFILE
SET LINESIZE 200
COL FILE_NAME FOR A70
SET FEEDBACK OFF
SET PAGESIZE 100
COL MEMBER FOR A60
SELECT FILE_NAME,BYTES/1024/1024 MBYTES FROM DBA_DATA_FILES;
SELECT FILE_NAME,BYTES/1024/1024 MBYTES FROM DBA_TEMP_FILES;
SELECT GROUP#,MEMBER FROM v\$LOGFILE;
SELECT NAME FROM V\$CONTROLFILE;
EXIT
EOF

$ORACLE_HOME/bin/rman <<EOF2 | tee -a $LOGFILE
connect target
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘/backup/ORCL1/jul16/ORCL1_rman_db_%U.bak’ MAXPIECESIZE 2000M;
backup database tag=’Full_DB_${CURRDATETIME}’ filesperset 3;
configure channel device type DISK format ‘/backup/ORCL1/jul16/ORCL1_rman_arch_%U.bak’ maxpiecesize 2000M;
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup tag=’Arch_Bkp_${CURRDATETIME}’ archivelog from time ‘sysdate – 2’;
delete noprompt archivelog all completed before ‘sysdate -2’;
configure channel device type DISK format ‘/backup/ORCL1/jul16/ORCL1_rman_db_%U.bak’ maxpiecesize 2000M;
copy current controlfile to ‘/backup/ORCL1/jul16/ORCL1_oscopy_ctrl_${CURRDATETIME}.ctl’;
backup spfile format ‘spfile_${CURRDATETIME}.ora’ tag=’spfile_${CURRDATETIME}’;
sql “alter database backup controlfile to trace”;
exit
EOF2

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (12 votes, average: 5.00 out of 5)
Loading...

2 thoughts on “RMAN Full Backup

Add Comment