一、RMAN全备份

删除不可用的备份:

crosscheck backup;
delete noprompt expired backup;

删除并过期备份

report obsolete;                  ##报告备份是否过期,备份是否过期,要根据rman指定的备份策略来衡量,如果未指定备份策略,则此条件不成立
delete noprompt obsolete;

在数据量比较小、或者数据库服务器性能很强大的情况下,可以每天进行一次全备份。

全被策略如下

1、crontab定时任务,避开业务繁忙时段

###########################################
## RMAN BACKUP
##
###########################################
0 4 * * * /u01/dba_scripts/rman/rman_full.sh

2、RMAN备份脚本

cat rman_full.sh.bak
source /home/oracle/.bash_profile
DAY_TAG=`date +"%Y-%m-%d"`
backdir1=/u03/paydb/backup/rman/
rm -rf $backdir1/*
rman target / nocatalog msglog /u01/dba_scripts/rman/log/fullback_$DAY_TAG.log<<EOF
run{
crosscheck backup;
delete noprompt expired backup;
allocate channel d1 type disk maxpiecesize = 3500M;    ----由于备份后,要把备份文件放到阿里云的OSS存储上面,但是OSS存储有4GB大小限制,因此,我们也要
allocate channel d2 type disk maxpiecesize = 3500M;    ----限制RMAN备份片的大小。
#crosscheck archivelog all;
#delete noprompt expired archivelog all;
#crosscheck backup;
#delete noprompt expired backup;
backup as compressed backupset database format '$backdir1/full_%d_%T_%t_%s_%p';
sql 'alter system archive log current';
backup as compressed backupset filesperset 10 format '$backdir1/arch_%d_%T_%t_%s_%p' archivelog all;
backup current controlfile format '$backdir1/ctl_%d_%T_%t_%s_%p';
release channel d1;
release channel d2;
#report obsolete;                  ##报告备份是否过期,备份是否过期,要根据rman指定的备份策略来衡量,如果未指定备份策略,则此条件不成立
#delete noprompt obsolete;
}
EOF

 

二、一级增量备份

1、crontab定时任务,避开业务繁忙时段

#***********************************
#    rman incremental backup   #
#        2017/8/7                         #
#***********************************
0 4 * * 0    /u03/rman_0_level_full.sh
0 4 * * 1-6  /u03/rman_1_level_incremental.sh

2、备份脚本

1)周末0级全备

cat rman_0_level_full.sh
source /home/oracle/.bash_profile
DAY_TAG=`date +"%Y-%m-%d"`
week=`date +%w`
backdir1=/u03/paydb/backup/rman/"$week"
rm -rf $backdir1/*
rman target / nocatalog msglog /u01/dba_scripts/rman/log/fullback_$DAY_TAG.log<<EOF
run{
crosscheck backup;
delete noprompt expired backup;
allocate channel d1 type disk maxpiecesize = 3500M;
allocate channel d2 type disk maxpiecesize = 3500M;
#crosscheck archivelog all;
#delete noprompt expired archivelog all;
#crosscheck backup;
#delete noprompt expired backup;
backup incremental level 0 as compressed backupset database format '$backdir1/full_%d_%T_%t_%s_%p';
sql 'alter system archive log current';
backup as compressed backupset filesperset 10 format '$backdir1/arch_%d_%T_%t_%s_%p' archivelog all;
backup current controlfile format '$backdir1/ctl_%d_%T_%t_%s_%p';
release channel d1;
release channel d2;
#report obsolete;
#delete noprompt obsolete;
}
EOF
2)周一到周六,针对周末的0级全备,每天进行1级增量备份
cat rman_1_level_incremental.sh
source /home/oracle/.bash_profile
DAY_TAG=`date +"%Y-%m-%d"`
week=`date +%w`
backdir1=/u03/paydb/backup/rman/"$week"
rm -rf $backdir1/*
rman target / nocatalog msglog /u01/dba_scripts/rman/log/fullback_$DAY_TAG.log<<EOF
run{
crosscheck backup;
delete noprompt expired backup;
allocate channel d1 type disk maxpiecesize = 3500M;
allocate channel d2 type disk maxpiecesize = 3500M;
#crosscheck archivelog all;
#delete noprompt expired archivelog all;
#crosscheck backup;
#delete noprompt expired backup;
backup incremental level 1 as compressed backupset database format '$backdir1/full_%d_%T_%t_%s_%p';
sql 'alter system archive log current';
backup as compressed backupset filesperset 10 format '$backdir1/arch_%d_%T_%t_%s_%p' archivelog all;
backup current controlfile format '$backdir1/ctl_%d_%T_%t_%s_%p';
release channel d1;
release channel d2;
#report obsolete;
#delete noprompt obsolete;
}
EOF

 

 posted on 2018-11-14 10:45  xibuhaohao  阅读(14108)  评论(4编辑  收藏  举报