ORACLE备份脚本(4-RMAN1级增量备份)

创建目录 

mkdir  -p  /bak/level1

mkdir  -p  /bak/arch1

chown -R oracle:oinstall  /bak/

 

vi  rmanlevel1.sh

 

#!/bin/bash

export ORACLE_SID=test
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_BASE=//u01/app/oracle
backtime=`date +"20%y%m%d%H%M%S"`
cd $ORACLE_HOME/bin
rman target / log=/bak/log/backupall_$backtime.log <<EOF

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

allocate channel c4 type disk;

backup as compressed backupset incremental level 1  database format '/bak/level1/level1_%d_%s_%p_%u.bak' tag 'level1' include current controlfile;

sql 'alter system archive log current';

backup as compressed backupset archivelog all format '/bak/arch1/log_%d_%s_%p_%u.bak' delete input ;

release channel c1;

release channel c2;

release channel c3;

release channel c4;

}

crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;

EOF

find /bak/level1/ -mtime +7 -name "*.bak" -exec rm -rf {} ;
find /bak/arch1/ -mtime +7 -name "*.bak" -exec rm -rf {} ;

原文地址:https://www.cnblogs.com/zhm1985/p/12691141.html