Oracle备份的方法很多,下面为您介绍的是windows环境下的oracle备份方法,如果您对Oracle备份方面感兴趣的话,不妨一看。
利用oracle的备份命名rman备份,这样就可以做完全备份和增量备份了,利用任务计划设置备份策略,比如每周一做0级备份,周二至周日做1级备份。注意利用rman做备份,必须启用归档日志模式。
1、建立0级备份批处理文件backup_0.bat,内容如下:
- set oracle_sid=oaserver
- rman target / msglog c:\logs\%date:~0,10%.log cmdfile=oaserver_backup_0.txt
2、然后创建负责Oracle备份的文件backup_0.txt,内容如下
- run{
- allocate channel 'd1' type disk;
- allocate channel 'd2' type disk;
- allocate channel 'd3' type disk;
- allocate channel 'd4' type disk;
- backup incremental level 0 cumulative tag 'db0' format 'E:\oaserver\backup\db0%u_%s_%p' database;
- sql 'alter system archive log current';
- backup filesperset 4 archivelog all delete input;
- delete noprompt obsolete;
- release channel d1;
- release channel d2;
- release channel d3;
- release channel d4;
- }
- list backup;
- crosscheck backup;
- delete noprompt expired backup;
- delete noprompt obsolete;
- exit;
- EOF
- echo "-------------------------end------------------------------";date
3、添加一个任务计划利用任务计划向导,根据Oracle备份策略设置自动执行任务的时间频率(例如每天零时),执行backup_0.bat
4、建立1级备份(增量备份)批处理文件backup_1.bat,内容如下:
- set oracle_sid=oaserver
- rman target / msglog c:\logs\%date:~0,10%.log cmdfile=oaserver_backup_1.txt
5、然后创建负责备份的文件backup_1.txt,内容如下
- run{
- allocate channel 'd1' type disk;
- allocate channel 'd2' type disk;
- allocate channel 'd3' type disk;
- allocate channel 'd4' type disk;
- backup incremental level 1 cumulative tag 'db1' format 'E:\oaserver\backup\db1%u_%s_%p' database;
- sql 'alter system archive log current';
- backup filesperset 4 archivelog all delete input;
- delete noprompt obsolete;
- release channel d1;
- release channel d2;
- release channel d3;
- release channel d4;
- }
- list backup;
- crosscheck backup;
- delete noprompt expired backup;
- delete noprompt obsolete;
- exit;
- EOF
- echo "-------------------------end------------------------------";date
6、添加一个任务计划利用任务计划向导,根据备份策略设置自动执行任务的时间频率(例如每天零时),执行backup_1.bat
【编辑推荐】