返回顶部

欢迎来到菜鸟大明儿哥的博客

我们一起交流学习,不断提升自我

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 {} \;

posted @ 2020-04-13 14:21  菜鸟大明儿哥  阅读(444)  评论(0编辑  收藏  举报