Windows环境下的Oracle数据库备份策略

最近公司一个新项目上线,服务器有限,无法搭建DG,特制定以下数据库备份策略:

1、每天凌晨1点进行数据库全库导出备份

代码清单:

expdp 数据库用户名/密码@IP地址/数据库实例名 schemas=模式名 directory=dumpdir dumpfile=备份文件.dmp version=11.1.0.7.0 logfile=备份文件名.log compression=all

PS:如果需要删除历史数据,可通过下列脚本:

del D:\backup\expdpbak\备份4.dmp 
rename D:\backup\expdpbak\备份3.dmp 备份4.dmp 
rename D:\backup\expdpbak\备份2.dmp 备份3.dmp 
rename D:\backup\expdpbak\备份1.dmp 备份2.dmp 
rename D:\backup\expdpbak\备份.dmp 备份1.dmp 
rename D:\backup\expdpbak\备份.log 备份1.log

2、每周一,周二,周三,周四,周五,周六进行RMAN增量备份

代码清单:

run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
sql "ALTER SYSTEM ARCHIVE LOG CURRENT";
backup incremental level=2 tag='db2' format 'D:\backup\rmanbak\db2%d_%T_%u'  database  plus archivelog  tag 'arch' format 'D:\backup\rmanbak\arch%T_%u_%s_%p';
crosscheck backup;
delete noprompt expired backup;
delete obsolete;
crosscheck archivelog all;
delete noprompt archivelog all completed before 'trunc(sysdate-1)' backed up 1 times to device type disk;
delete noprompt expired archivelog all;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

3、每周日进行RMAN全量备份

run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
configure retention policy to recovery window of 4 days;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to 'D:\backup\rmanbak\ctl_%F';

sql "ALTER SYSTEM ARCHIVE LOG CURRENT";
backup  as compressed backupset incremental level=0 tag='db0' format 'D:\backup\rmanbak\db0%d_%T_%u'  database  plus archivelog  tag 'arch' format 'D:\backup\rmanbak\arch%T_%u_%s_%p';
crosscheck backup;
delete noprompt expired backup;
delete obsolete;
crosscheck archivelog all;
delete noprompt archivelog all completed before 'trunc(sysdate-1)' backed up 1 times to device type disk;
delete noprompt expired archivelog all;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

4、每周日凌晨进行日志清理操作

代码清单:

crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog all completed before 'trunc(sysdate-2)';
crosscheck archivelog all;
delete noprompt expired archivelog all;

5、考虑到单点故障带来的风险,建议将备份文件定期拷贝至NAS存储设备

代码清单:

xcopy D:\backup\expdpbak\*.DMP  Z:\bak\ /d /y
xcopy D:\backup\expdpbak\*.log  Z:\bak\ /d /y

你可能感兴趣的:(Oracle日常管理)