rman备份方法之-增量备份
使用类型:系统负载集中在某那个时间段,如白天8小时,晚上基本很闲,所以在晚上就可以对数据进行备份 与之相对应的是全库备份: http://blog.csdn.net/jacson_bai/article/details/39636915 1、ENV: IP: 10.244.171.180/181 Oracle database Oracle 11.2.0.
使用类型:系统负载集中在某那个时间段,如白天8小时,晚上基本很闲,所以在晚上就可以对数据进行备份
与之相对应的是全库备份:
http://blog.csdn.net/jacson_bai/article/details/39636915
1、ENV:
IP: 10.244.171.180/181
Oracle database Oracle 11.2.0.3
OS RHEL 5.5
Backup Toos:RMAN,shell,crontab
2、备份计划(增量计划)
Sunday :execute level 0 incremental back
Monday :execute level 2 incremental back
Tuesday :execute level 2 incremental back
Wednesday:execute level 1 incremental back
Thursday :execute level 2 incremental back
Friday :execute level 2 incremental back
Saturday :execute level 2 incremental back
3、在Node2规划backup 目录
--先创建保存备份脚本的目录
$mkdir -p /Data/scripts/rman/
--创建备份数据的目录
$mkdir -p /Data/rmandata/ --存放备份的数据目录
3、制定*.sql和rman_backup.sh脚本
--全备lv0级:
$cd /Data/scripts/rman/
$vi backup_lv0.sql
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup incremental level 0 database
include current controlfile format '/Data/rmandata/backup_%T_%s_%U_%t.lv0'
plus archivelog delete all input format '/Data/arch/backup_%T_%s_%p_%t.arc';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
--增量备lv1级:
vi backup_lv1.sql
run{
allocate channel c1 type disk;
backup incremental level 1 database include current controlfile
format '/Data/rmandata/backup_%T_%s_%p.lv1';
release channel c1;
}
--累计备lv2级:
$vi backup_lv2.sql
run{
allocate channel c1 type disk;
backup incremental level 2 database include current controlfile
format '/Data/rmandata/backup_%T_%s_%p.lv2';
release channel c1;
}
4、编写shell脚本
--脚本要实现的功能:
1.正确判断星期
2.记录每个rman备份运行的时间
#!/bin/bash
source /home/oracle/.bash_profile
myweek=`date +%a`
mydate=`date +%Y%m%d`
mydir=/Data/
#Monday
if [ "$myweek" == "Mon" ]; then
rman target sys/oracle msglog=${mydir}/backup_${mydate}.log cmdfile=${mydir}/scripts/rman/backup_lv2.sql
fi
#Tuesday
if [ "$myweek" == "Tue" ]; then
rman target sys/oracle msglog=${mydir}/backup_${mydate}.log cmdfile=${mydir}/scripts/rman/backup_lv2.sql
fi
#Wednesday
if [ "$myweek" == "Wed" ]; then
rman target sys/oracle msglog=${mydir}/backup_${mydate}.log cmdfile=${mydir}/scripts/rman/backup_lv1.sql
fi
#Thursday
if [ "$myweek" == "Thu" ]; then
rman target sys/oracle msglog=${mydir}/backup_${mydate}.log cmdfile=${mydir}/scripts/rman/backup_lv2.sql
fi
#Friday
if [ "$myweek" == "Fri" ]; then
rman target sys/oracle msglog=${mydir}/backup_${mydate}.log cmdfile=${mydir}/scripts/rman/backup_lv2.sql
fi
#Saturday
if [ "$myweek" == "Sat" ]; then
rman target sys/oracle msglog=${mydir}/backup_${mydate}.log cmdfile=${mydir}/scripts/rman/backup_lv2.sql
fi
#Sunday
if [ "$myweek" == "Sun" ]; then
rman target sys/oracle msglog=${mydir}/backup_${mydate}.log cmdfile=${mydir}/scripts/rman/backup_lv0.sql
fi
5、crontab脚本指定
$crontab -e
30 20 * * * sh /Data/script/rman/rman_backup.sh;