linux下 oracle rman 备份脚本

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:31

[backcolor=inherit]创建rman恢复目录:
[backcolor=inherit]1、create tablespace rman_ts datafile 'd:\arch\rman_ts.dbf' size 20M;
[backcolor=inherit]2、create user rman identified by rman default tablespace rman_ts temporary tablespace temp quota unlimited on rman_ts;
[backcolor=inherit]3、grant recovery_catalog_owner to rman;
[backcolor=inherit]4、grant connect,resource to rman;
[backcolor=inherit]5、rman catalog rman/rman
[backcolor=inherit]6、create catalog tablespace rman_ts;
[backcolor=inherit]7、rman target sys/admin@t60 catalog rman/rman@ibm
[backcolor=inherit]8、register database;
[backcolor=inherit]--------------------------------
[backcolor=inherit]vi connect.rcv
[backcolor=inherit]connect catalog rman/admin@bk;
[backcolor=inherit]connect target sys/admin@orcl2;
[backcolor=inherit]==============================
[backcolor=inherit](备份归档日志)
[backcolor=inherit]replace global script global_arch comment "backup archivelog as well as delete input"
[backcolor=inherit]{
[backcolor=inherit]allocate channel d1 device type disk;
[backcolor=inherit]sql "alter system archive log current";
[backcolor=inherit]set limit channel d1 readrate=10240;
[backcolor=inherit]set limit channel d1 kbytes=4096000;
[backcolor=inherit]backup as compressed backupset
[backcolor=inherit]format='/u01/app/arch_bk/arch_%d_%u.log'
[backcolor=inherit]channel=d1
[backcolor=inherit]tag='arch_log'
[backcolor=inherit]archivelog all delete input;
[backcolor=inherit]release channel d1;
[backcolor=inherit]}

[backcolor=inherit]----------------------------------
[backcolor=inherit](备份控制文件)
[backcolor=inherit]replace global script global_bkctl comment "backup controlfile"
[backcolor=inherit]{
[backcolor=inherit]allocate channel d1 device type disk;
[backcolor=inherit]backup as compressed backupset format='/u01/app/arch_bk/orcl2.ctl' tag='orcl2_bk_ctl' channel=d1 current controlfile reuse;
[backcolor=inherit]release channel d1;
[backcolor=inherit]}

[backcolor=inherit]-----------------------------
[backcolor=inherit](删除过期备份文件)
[backcolor=inherit]replace global script global_del comment "delete over 15 days"
[backcolor=inherit]{
[backcolor=inherit]allocate channel d1 device type disk;
[backcolor=inherit]delete obsolete recovery window of 15 days;
[backcolor=inherit]release channel d1;
[backcolor=inherit]}

[backcolor=inherit]----------------------------

[backcolor=inherit]replace global script global_inc0 comment "backup database inc0"
[backcolor=inherit]{
[backcolor=inherit]execute global script global_del;
[backcolor=inherit]allocate channel d1 device type disk;
[backcolor=inherit]set limit channel d1 readrate=10240;
[backcolor=inherit]set limit channel d1 kbytes=4096000;
[backcolor=inherit]backup as compressed backupset
[backcolor=inherit]incremental level=0
[backcolor=inherit]format='/u01/app/arch_bk/db_inc0_%d_%u.bak'
[backcolor=inherit]tag='inc0'
[backcolor=inherit]channel=d1
[backcolor=inherit]database;
[backcolor=inherit]release channel d1;
[backcolor=inherit]execute global script global_arch;
[backcolor=inherit]execute global script global_bkctl;
[backcolor=inherit]}

[backcolor=inherit]---------------------------------
[backcolor=inherit]replace global script global_inc1 comment "backup database inc1"
[backcolor=inherit]{
[backcolor=inherit]execute global script global_del;
[backcolor=inherit]allocate channel d1 device type disk;
[backcolor=inherit]set limit channel d1 readrate=10240;
[backcolor=inherit]set limit channel d1 kbytes=4096000;
[backcolor=inherit]backup as compressed backupset
[backcolor=inherit]incremental level=1
[backcolor=inherit]format='/u01/app/arch_bk/db_inc1_%d_%u.bak'
[backcolor=inherit]tag='inc1'
[backcolor=inherit]channel=d1
[backcolor=inherit]database;
[backcolor=inherit]release channel d1;
[backcolor=inherit]execute global script global_arch;
[backcolor=inherit]execute global script global_bkctl;
[backcolor=inherit]}
[backcolor=inherit]-------------------------------
[backcolor=inherit]replace global script global_inc2 comment "backup database inc2"
[backcolor=inherit]{
[backcolor=inherit]execute global script global_del;
[backcolor=inherit]allocate channel d1 device type disk;
[backcolor=inherit]set limit channel d1 readrate=10240;
[backcolor=inherit]set limit channel d1 kbytes=4096000;
[backcolor=inherit]backup as compressed backupset
[backcolor=inherit]incremental level=2
[backcolor=inherit]format='/u01/app/arch_bk/db_inc2_%d_%u.bak'
[backcolor=inherit]tag='inc2'
[backcolor=inherit]channel=d1
[backcolor=inherit]database;
[backcolor=inherit]release channel d1;
[backcolor=inherit]execute global script global_arch;
[backcolor=inherit]execute global script global_bkctl;
[backcolor=inherit]}

[backcolor=inherit]==============================================
[backcolor=inherit]测试脚本:
[backcolor=inherit]============================================
[backcolor=inherit]run {
[backcolor=inherit]execute global script global_inc0;
[backcolor=inherit]execute global scripe global_inc1;
[backcolor=inherit]execute global script global_inc2;
[backcolor=inherit]}
[backcolor=inherit]-------

[backcolor=inherit]vi inc0.rcv
[backcolor=inherit]@@/rmanbak/script/connect.rcv
[backcolor=inherit]run{
[backcolor=inherit]execute global script global_inc0;
[backcolor=inherit]}
[backcolor=inherit]exit
[backcolor=inherit]-------

[backcolor=inherit]vi inc1.rcv
[backcolor=inherit]@@/rmanbak/script/connect.rcv
[backcolor=inherit]run{
[backcolor=inherit]execute global script global_inc1;
[backcolor=inherit]}
[backcolor=inherit]exit

[backcolor=inherit]vi inc2.rcv
[backcolor=inherit]@@/rmanbak/script/connect.rcv
[backcolor=inherit]run{
[backcolor=inherit]execute global script global_inc2;
[backcolor=inherit]}
[backcolor=inherit]exit

[backcolor=inherit]vi inc0.sh
[backcolor=inherit]nohup $ORACLE_HOME/bin/rman cmdfile=/rmanbak/script/inc0.rcv log=/rmanbak/script/inc0.log append &

[backcolor=inherit]vi inc1.sh
[backcolor=inherit]nohup $ORACLE_HOME/bin/rman cmdfile=/rmanbak/script/inc1.rcv log=/rmanbak/script/inc1.log append &

[backcolor=inherit]vi inc2.sh
[backcolor=inherit]nohup $ORACLE_HOME/bin/rman cmdfile=/rmanbak/script/inc2.rcv log=/rmanbak/script/inc2.log append &
[backcolor=inherit]修改以上脚本的执行权限

[backcolor=inherit]crontab -e 编辑备份计划

[backcolor=inherit]#min hour date mon day command
[backcolor=inherit]0 21 * * 0 su - oracle -c /u01/sh/inc0.sh
[backcolor=inherit]0 21 * * 1 su - oracle -c /u01/sh/inc2.sh
[backcolor=inherit]0 21 * * 2 su - oracle -c /u01/sh/inc2.sh
[backcolor=inherit]0 21 * * 3 su - oracle -c /u01/sh/inc2.sh
[backcolor=inherit]0 21 * * 4 su - oracle -c /u01/sh/inc1.sh
[backcolor=inherit]0 21 * * 5 su - oracle -c /u01/sh/inc2.sh
[backcolor=inherit]0 21 * * 6 su - oracle -c /u01/sh/inc2.sh

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】