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

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

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

startup mount
alter database archivelog
alter database open
2.连接到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 compressed
backupset; --压缩
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 performed
2.星期二晚上-level 2 backup performed
3.星期三晚上-level 1 backup performed
4.星期四晚上-level 2 backup performed
5.星期五晚上-level 2 backup performed
6.星期六晚上-level 2 backup performed
如果星期二需要恢复的话,只需要0+1,
如果星期四需要恢复的话,只需要0+3,
如果星期五需要恢复的话,只需要0+3+4,
如果星期六需要恢复的话,只需要0+3+4+5
具体步骤:
1.创建0,1,2级备份脚本 D:\rman_bak_script
run{
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 / log
D:\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 / log
D:\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 / log
D:\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 / log
D:\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 / log
D:\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 / log
D:\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 / log
D:\rman_bak_script\Sat\rmanlog_Sat%date:~0,4%_%date:~5,2%_%date:~8,2%.txt cmdfile=D:\rman_bak_script\rman_level2.cmd
3.创建任务计划。

相关文档
最新文档