博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

oracle的备份与恢复的批处理

Posted on 2011-04-21 14:35  codingsilence  阅读(211)  评论(0编辑  收藏  举报

================备份=================================
rman target /  cmdfile=/oracle/shell/cfg/bakDB.rcv trace /oracle/shell/logs/bakfull.log &

CONFIGURE DEVICE TYPE DISK PARALLELISM 8;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   '/rman01/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/rman02/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT   '/rman03/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 4 DEVICE TYPE DISK FORMAT   '/rman04/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 5 DEVICE TYPE DISK FORMAT   '/rman05/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 6 DEVICE TYPE DISK FORMAT   '/rman06/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 7 DEVICE TYPE DISK FORMAT   '/rman07/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 8 DEVICE TYPE DISK FORMAT   '/rman08/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
run
{
sql "Alter System Archive Log Current";
BACKUP FILESPERSET=32 DATABASE plus archivelog format '/rman02/arch_%d_%T_%s';
sql "alter database backup controlfile to ''/rman01/controlfile/copy_current_controlfile'' reuse";
}
=================恢复================================
rman target / nocatalog cmdfile=./restoreDB.rcv trace ./restoreDB.log &


------------------restoreDB.rcv----------------------------------------------
STARTUP NOMOUNT;
SET DBID 3658411712;    # required when restoring control file in NOCATALOG mode
run
{
CONFIGURE DEVICE TYPE DISK PARALLELISM 8;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   '/rman01/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/rman02/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT   '/rman03/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 4 DEVICE TYPE DISK FORMAT   '/rman04/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 5 DEVICE TYPE DISK FORMAT   '/rman05/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 6 DEVICE TYPE DISK FORMAT   '/rman06/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 7 DEVICE TYPE DISK FORMAT   '/rman07/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
CONFIGURE CHANNEL 8 DEVICE TYPE DISK FORMAT   '/rman08/bak_ful/dbf_%T_%s_%p' MAXPIECESIZE 8 G;
restore controlfile from '/rman01/controlfile/copy_current_controlfile';
alter database mount;
RESTORE DATABASE;
recover database until cancel;
}