当前位置:文档之家› oracle数据库全备份和增量备份

oracle数据库全备份和增量备份

1. 检查数据库模式:sqlplus /nologconn /as sysdbaarchive log list (查看数据库是否处于归档模式中)若为非归档,则修改数据库归档模式。

startup mountalter database archivelogalter database open2.连接到target数据库命令:connect target / (connect target system/oracle@ora10g,如果数据库没有起来,也可要直接在rman命令下用startup进行启动数据库)可以连接到target database.(rman 一边连接到target数据库,另外一边连接到control file(nocatalog mode),control file 中存储rman 的备份信息)3.用list backupset 命令查看有没有备份4. 常用备份命令:备份全库:RMAN> backup database plus archivelog delete input; (备份全库及控制文件、服务器参数文件与所有归档的重做日志,并删除旧的归档日志)备份表空间:RMAN> backup tablespace system plus archivelog delete input; (备份指定表空间及归档的重做日志,并删除旧的归档日志)_备份归档日志:RMAN> backup archivelog all delete input;1.全库备份(备份数据文件中有数据的,有数据文件,控制文件,归档日志文件,spfile文件,不备份联机重做日志文件或临时文件)RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; --控制文件自动备份RMAN>CONFIGURE DEVICE TYPE DISK PARALLELISM 2 backup type to compressedbackupset; --压缩RMAN> CONFIGURE channel DEVICE TYPE DISK format 'D:\APP\rman\full_%s.bk'; --备份的路径RMAN>BACKUP DATABASE; --全备份RMAN>list backup of database; --检查备份信息RMAN>backup archivelog all delete input; --备份归档日志并删除归档日志RMAN> list backup of archivelog all; --检查归档日志2.差异增量备份RMAN> backup incremental level 0 database; --0级全备份RMAN> backup incremental level 2 database;--2级备份RMAN> list backup of database; --检查备份信息3.累积增量备份(2c 不做参照对象)RMAN> backup incremental level 2 cumulative database;中心数据库,RMAN一周备份方案============================0.星期天晚上-level 0 backup performed(全备份)1.星期一晚上-level 2 backup performed2.星期二晚上-level 2 backup performed3.星期三晚上-level 1 backup performed4.星期四晚上-level 2 backup performed5.星期五晚上-level 2 backup performed6.星期六晚上-level 2 backup performed如果星期二需要恢复的话,只需要0+1,如果星期四需要恢复的话,只需要0+3,如果星期五需要恢复的话,只需要0+3+4,如果星期六需要恢复的话,只需要0+3+4+5具体步骤:1.创建0,1,2级备份脚本 D:\rman_bak_scriptrun{allocate channel c1 type disk;allocate channel c2 type disk;allocate channel c3 type disk;backup as compressed backupset incremental level 0 tag 'db_level0' database format 'H:\RMAN_BAK\level0_%u_%s_%p.bak';sql 'alter system archive log current';backup as compressed backupset archivelog all format'H:\ARCHIVELOG_BAK\arch0_%u_%s_%p' delete input;delete noprompt obsolete;release channel c1;release channel c2;release channel c3;}run{allocate channel c1 type disk;allocate channel c2 type disk;allocate channel c3 type disk;backup as compressed backupset incremental level 1 tag 'db_level1' database format 'H:\RMAN_BAK\level1_%u_%s_%p.bak';sql 'alter system archive log current';backup as compressed backupset archivelog all format 'H:\ARCHIVELOG_BAK\arch1_%u_%s_%p' delete input;delete noprompt obsolete;release channel c1;release channel c2;release channel c3;}run{allocate channel c1 type disk;allocate channel c2 type disk;allocate channel c3 type disk;backup as compressed backupset incremental level 2 tag 'db_level2' database format 'H:\RMAN_BAK\level2_%u_%s_%p.bak';sql 'alter system archive log current';backup as compressed backupset archivelog all format 'H:\ARCHIVELOG_BAK\arch2_%u_%s_%p' delete input;delete noprompt obsolete;release channel c1;release channel c2;release channel c3;}2.创建周日至周六执行的批处理文件 D:\rman_bak_script\Mon…Sun星期天rman target / logD:\rman_bak_script\Sun\rmanlog_Sun%date:~0,4%_%date:~5,2%_%date:~8,2%.txt cmdfile=D:\rman_bak_script\rman_level0.cmd星期一 rman target / logD:\rman_bak_script\Mon\rmanlog_Mon%date:~0,4%_%date:~5,2%_%date:~8,2%.txt cmdfile=D:\rman_bak_script\rman_level2.cmd星期二rman target / logD:\rman_bak_script\Tue\rmanlog_Tue%date:~0,4%_%date:~5,2%_%date:~8,2%.txt cmdfile=D:\rman_bak_script\rman_level2.cmd星期三rman target / logD:\rman_bak_script\Wen\rmanlog_Wen%date:~0,4%_%date:~5,2%_%date:~8,2%.txt cmdfile=D:\rman_bak_script\rman_level1.cmd星期四rman target / logD:\rman_bak_script\Thu\rmanlog_Thu%date:~0,4%_%date:~5,2%_%date:~8,2%.txt cmdfile=D:\rman_bak_script\rman_level2.cmd星期五rman target / logD:\rman_bak_script\Fri\rmanlog_Fri%date:~0,4%_%date:~5,2%_%date:~8,2%.txt cmdfile=D:\rman_bak_script\rman_level2.cmd星期六rman target / logD:\rman_bak_script\Sat\rmanlog_Sat%date:~0,4%_%date:~5,2%_%date:~8,2%.txt cmdfile=D:\rman_bak_script\rman_level2.cmd3.创建任务计划。

相关主题