一、RMAN全备份
在数据量比较小、或者数据库服务器性能很强大的情况下,可以每天进行一次全备份。
全被策略如下
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;
#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级全备
week=`date +%w`
DAY_TAG=`date +"%Y-%m-%d"`
backdir=/u03/paydb/backup/rman/$week
rm -rf $backdir/*
run{
allocate channel d1 type disk;
allocate channel d2 type disk;
#crosscheck archivelog all;
#delete noprompt expired archivelog all;
#crosscheck backup;
#delete noprompt expired backup;
backup incremental level 0 as compressed backupset database format ' $backdir/full_%d_%T_%s';
sql 'alter system archive log current';
backup as compressed backupset filesperset 10 format ' $backdir/arch_%d_%T_%s' archivelog all;
backup current controlfile format ' $backdir/ctl_%d_%T_%s';
release channel d1;
release channel d2;
#report obsolete;
#delete noprompt obsolete;
}
EOF
week=`date +%w`
DAY_TAG=`date +"%Y-%m-%d"`
backdir=/u03/paydb/backup/rman/$week
rm -rf $backdir/*
run{
allocate channel d1 type disk;
allocate channel d2 type disk;
#crosscheck archivelog all;
#delete noprompt expired archivelog all;
#crosscheck backup;
#delete noprompt expired backup;
backup incremental level 1 cumulative database format ' $backdir/incremental _%d_%T_%s';
sql 'alter system archive log current';
backup as compressed backupset filesperset 10 format ' $backdir/arch_%d_%T_%s' archivelog all;
backup current controlfile format ' $backdir/ctl_%d_%T_%s';
release channel d1;
release channel d2;
#report obsolete;
#delete noprompt obsolete;
}
EOF