发布于 2016-03-26 21:55:59 | 130 次阅读 | 评论: 0 | 来源: 网友投递
RMan Oracle数据库备份和恢复工具
RMAN 可以用来备份和恢复数据库文件、归档日志和控制文件,也可以用来执行完全或不完全的数据库恢复。RMAN有三种不同的用户接口:COMMAND LINE方式、GUI 方式(集成在OEM 中的备份管理器)、API 方式(用于集成到第三方的备份软件中)。
一、增量备份脚本
0级备份脚本:红色部分为自定义的备份文件放置的目录
#script.:BackupFull.sh
#creater:xyh
#date:2014-03-08
#desc:backup full database datafile in archive with rman
#connect database
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
rman target/ << EOF_RMAN
run{
allocate channel c1 type disk;
backup incremental level 0 tag 'db0' format
'/home/oracle/RmanBackup/db0_%d_%T_%s' database include current controlfile;
sql 'alter system archive log current';
backup filesperset 5 format '/home/oracle/RmanBackup/cf0_%d_%T_%s' archivelog all delete input;
#filesperset 5表示备份集里面最多包含5个文件
delete noprompt obsolete;
release channel c1;
}
# end
1级备份脚本
#script.:Incrl.sh
#creater:xyh
#date:2014-03-08
#desc:backup full database datafile in archive with rman
#connect database
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
rman target/ << EOF_RMAN
run{
allocate channel c1 type disk;
backup incremental level 1 tag 'db1' format
'/home/oracle/RmanBackup/db1_%d_%T_%s' database include current controlfile;
sql 'alter system archive log current';
backup filesperset 5 format '/home/oracle/RmanBackup/cf1_%d_%T_%s' archivelog all delete input;
#filesperset 5表示备份集里面最多包含5个文件
delete noprompt obsolete;
release channel c1;
}
#end
crontab -e
0 1 * * 0 /home/oracle/BackupFull.sh >>/home/oracle/BackupFull.log
0 1 * * 3 /home/oracle/BackupFull.sh >>/home/oracle/BackupFull.log
30 1 * * 1-2 /home/oracle/Incrl.sh >>/home/oracle/Incr.log
30 1 * * 4-6 /home/oracle/Incrl.sh >>/home/oracle/Incr.log