温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

ORCLE RMAN备份脚本

发布时间:2020-06-28 08:44:04 来源:网络 阅读:1242 作者:luoyangzhigui 栏目:关系型数据库

1、Linux下oracle备份脚本

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

export PATH=$PATH:$ORACLE_HOME/bin:

export NLS_LANG=AMERICAN_AMERICA.zhs16gbk

export ORACLE_SID=orcl

rman target / nocatalog log=/tmp/rman_full.log append<<EOF

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup filesperset 3 database format '/oracle/backup/full_%d_%T_%s_%p';

sql 'alter system archive log current';

sql 'alter system archive log current';

sql 'alter system archive log current';

backup archivelog all format '/oracle/backup/arch_%d_%T_%s_%p' delete input;

backup current controlfile format '/oracle/backup/ctl_%d_%T_%s_%p';

}

EOF


Linux下删除过期备份的脚本

rman target / nocatalog log=/tmp/rman_delete.log append<<EOF

run{

allocate channel for maintenance type disk;

crosscheck backup;

crosscheck archivelog all;

delete noprompt archivelog until time 'sysdate-1';

delete noprompt obsolete;

}

EOF


注:将脚本添加到crontab中定时执行即可。


2、windows下ORACLE备份脚本

全库备份脚本full_backup.txt

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup filesperset 2 database format 'd:\u01\rman\full_%d_%T_%s_%p';

sql 'alter system archive log current';

sql 'alter system archive log current';

sql 'alter system archive log current';

backup archivelog all format 'd:\u01\rman\arch_%d_%T_%s_%p' delete input;

backup current controlfile format 'd:\u01\rman\ctl_%d_%T_%s_%p';

backup spfile format 'd:\u01\rman\spfile_%d_%T_%s_%p';

}

exit


全库备份可执行脚本full_backup.bat

rman target / nocatalog log=d:\u01\rman.log append CMDFILE 'd:\u01\full_backup.txt';


归档日志备份脚本log_backup.txt

run{

backup archivelog all format 'd:\u01\rman\arch_%d_%T_%s_%p' delete input;

}

exit


删除过期备份脚本delete_obsolete.txt

run{

crosscheck backup;

crosscheck archivelog all;

delete noprompt archivelog until time 'sysdate-1';

delete noprompt obsolete; 

}

exit


注:windows下备份需要添加定时任务

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI