日常习惯使用netbackup进行数据库备份,但是经常环境中无netbackup,因此的自己写个脚本,脚本很简单,主要是写费时间,因此贴出来以备后用:
全备:
cat arch_rman_backup.sh:
source /home/oracle/.bash_profile
rman target / log=/u01/app/script/arch_rman.log<<EOF
run
{
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
sql 'alter system archive log current';
#backup database format '/backup/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/backup/arch_%U_%d_%T_%t' delete all input;
backup current controlfile format '/backup/ctl_%U_%d_%T_%t';
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt obsolete;
#delete noprompt backup of database completed before 'sysdate -7';
#delete noprompt archivelog all;
#delete noprompt backup of archivelog all completed before 'sysdate -7';
release channel ch2;
release channel ch3;
}
EOF
归档日志备份:
$cat arch_rman_backup.sh
source /home/oracle/.bash_profile
rman target / log=/u01/app/script/arch_rman.log<<EOF
run
{
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
sql 'alter system archive log current';
#backup database format '/backup/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/backup/arch_%U_%d_%T_%t' delete all input;
backup current controlfile format '/backup/ctl_%U_%d_%T_%t';
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt obsolete;
#delete noprompt backup of database completed before 'sysdate -7';
#delete noprompt archivelog all;
#delete noprompt backup of archivelog all completed before 'sysdate -7';
release channel ch2;
release channel ch3;
}
EOF
添加执行权限:
chmod +x /u01/app/script/arch_rman_backup.sh
chmod +x /u01/app/script/full_rman_backup.sh
设置备份保留策略:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
添加定时任务:
0 */2 * * * /u01/app/script/arch_rman_backup.sh
30 1 * * 0 /u01/app/script/full_rman_backup.sh
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。