欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

oracle备份方案

程序员文章站 2022-06-17 21:55:32
[toc] oracle生产备份方案 crontab 配置 周末全量备份,其他日期增量备份,清除15天以前文件 rman_backup_0.sh !/bin/bash source ~/.bash_profile rq= rman target / log /backup/log/rmanbacku ......

目录

oracle生产备份方案

crontab 配置

周末全量备份,其他日期增量备份,清除15天以前文件

0 5 * * * find /app/oracle11g/product/11.2.0/archdir/ecudb/* -mtime +6 |xargs  rm -fr

#rmanbackup
30 4 * * 6  sh /backup/feikong/scripts/rman_backup_0.sh
30 4 * * 0,1,2,3,4,5  sh /backup/feikong/scripts/rman_backup_1.sh
30 4 * * * find /backup/data -ctime +15 -type f |grep -e "db_0|db_1|arch_" |xargs -l 1 rm -rf

rman_backup_0.sh

#!/bin/bash
source ~/.bash_profile
rq=`date +%y%m%d`
rman target / log /backup/log/rmanbackup_${rq}.log append<<eof
set encryption on identified by "u9j04hkuvfru" only;
run{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup incremental level 0 tag "db0" database format "/backup/data/db_0_%t%u.bkp";
crosscheck archivelog all;
delete noprompt expired archivelog all;
sql "alter system archive log current";
backup archivelog all format "/backup/data/arch_%t%u.arc";
delete noprompt backup of archivelog until time "sysdate-8";
backup current controlfile format "/backup/data/ctl_%t%u.ctl";
crosscheck backup;
crosscheck backupset;
delete noprompt expired backup;
delete noprompt expired backupset;
report obsolete;
delete noprompt obsolete device type disk; 
release channel ch1;
release channel ch2;
}
exit
eof

rman_backup_1.sh

#!/bin/bash
source ~/.bash_profile
rq=`date +%y%m%d`
rman target / log /backup/log/rmanbackup_${rq}.log append<<eof
set encryption on identified by "u9j04hkuvfru" only;
run{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup incremental level 1 tag "db1" database format "/backup/data/db_1_%t%u.bkp";
crosscheck archivelog all;
delete noprompt expired archivelog all;
sql "alter system archive log current";
backup archivelog all format "/backup/data/arch_%t%u.arc";
delete noprompt backup of archivelog until time "sysdate-8";
backup current controlfile format "/backup/data/ctl_%t%u.ctl";
crosscheck backup;
crosscheck backupset;
delete noprompt expired backup;
delete noprompt expired backupset;
report obsolete;
delete noprompt obsolete device type disk; 
release channel ch1;
release channel ch2;
}
exit
eof