1.CHUẨN BỊ SCRIPT
# $Header: rman_level0_bkp.sh
# *======================================================================+
# | Author - TRAN VAN BINH - ORACLE DBA VIETNAM
# | |
# +=====================================================================+
# |
# | DESCRIPTION
# | Take rman full backup(incremental level 0 )
# | PLATFORM
# | Linux/Solaris/HP-UX
# +=====================================================================+
#!/bin/bash
RMANBACKUP_MOUNTPOINT1=/u01/oracle/rman_bkp
PARALLELISM=4
MAXPIECESIZE=3g
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
export ORACLE_SID=TESTDB
export PATH=$ORACLE_HOME/bin:$PATH
fullBackup () {
rman log=/u01/oracle/rman_bkp/LOG/RMANLevel0incr.log << EOF
connect target /
set echo on;
configure backup optimization on;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '$RMANBACKUP_MOUNTPOINT1/%F';
configure maxsetsize to unlimited;
configure device type disk parallelism $PARALLELISM;
run
{
allocate channel c1 type disk format '${RMANBACKUP_MOUNTPOINT1}/%I-%Y%M%D-%U' maxpiecesize ${MAXPIECESIZE};
allocate channel c2 type disk format '${RMANBACKUP_MOUNTPOINT1}/%I-%Y%M%D-%U' maxpiecesize ${MAXPIECESIZE};
allocate channel c3 type disk format '${RMANBACKUP_MOUNTPOINT1}/%I-%Y%M%D-%U' maxpiecesize ${MAXPIECESIZE};
allocate channel c4 type disk format '${RMANBACKUP_MOUNTPOINT1}/%I-%Y%M%D-%U' maxpiecesize ${MAXPIECESIZE};
backup as compressed backupset incremental level 0 check logical database plus archivelog;
release channel c1 ;
release channel c2 ;
release channel c3 ;
release channel c4 ;
}
configure backup optimization clear;
configure controlfile autobackup clear;
sql 'alter system archive log current';
exit
EOF
}
# Main
fullBackup
SCRIPT: ( rman_level1_bkp.sh)
# $Header: rman_inc_bkp.sh
# +=====================================================================+
# | Author - TRAN VAN BINH - ORACLE DBA VIETNAM
# | |
# +=====================================================================+
# |
# | DESCRIPTION
# | Take rman incemental backup(incremental level 1 )
# | PLATFORM
# | Linux/Solaris/HP-UX
# +=====================================================================+
#!/bin/bash
RMANBACKUP_MOUNTPOINT1=/u01/oracle/rman_bkp
PARALLELISM=4
MAXPIECESIZE=3g
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
export ORACLE_SID=TESTDB
export PATH=$ORACLE_HOME/bin:$PATH
fullBackup () {
rman log=/u01/oracle/rman_bkp/LOG/RMANLevel1incr.log << EOF
connect target /
set echo on;
configure backup optimization on;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '$RMANBACKUP_MOUNTPOINT1/%F';
configure maxsetsize to unlimited;
configure device type disk parallelism $PARALLELISM;
run
{
allocate channel c1 type disk format '${RMANBACKUP_MOUNTPOINT1}/%I-%Y%M%D-%U' maxpiecesize ${MAXPIECESIZE};
allocate channel c2 type disk format '${RMANBACKUP_MOUNTPOINT1}/%I-%Y%M%D-%U' maxpiecesize ${MAXPIECESIZE};
allocate channel c3 type disk format '${RMANBACKUP_MOUNTPOINT1}/%I-%Y%M%D-%U' maxpiecesize ${MAXPIECESIZE};
allocate channel c4 type disk format '${RMANBACKUP_MOUNTPOINT1}/%I-%Y%M%D-%U' maxpiecesize ${MAXPIECESIZE};
backup as compressed backupset incremental level 1 check logical database plus archivelog;
release channel c1 ;
release channel c2 ;
release channel c3 ;
release channel c4 ;
}
configure backup optimization clear;
configure controlfile autobackup clear;
sql 'alter system archive log current';
exit
EOF
}
# Main
fullBackup
2. Gán quyền
chmod 755 rman_level0_bkp.sh
chmod 755 rman_level1_bkp.sh
3. Cấu hình crontab để chạy tự động
-- Backup full (level 0) vào thứ 4, chủ nhật
00 00 * * 3,6 "/u01/app/oracle/rman_lelve0_bkp.sh" > /tmp/rman_level0.log
-- Backup incremental (level 1) vào các ngày còn lại
00 00 * * 1,2,4,5,0 "/u01/app/oracle/rman_level1_bkp.sh" > /tmp/rman_level1.log
#OracleTutorial
#OracleDBA
#OracleDatabaseAdministration
#học oracle database
#oca
#ocp
#oce