oracle11gr1 RMAN bakcup and restore

jasperjohn發表於2012-08-09
rman target /
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON;

backupscript.:
run
{
Crosscheck backup;
Crosscheck archivelog all;
delete NOPROMPT expired backup;
delete NOPROMPT OBSOLETE;
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup full database tag 'FullBackup' format '/oracle/backup/db_full_%T_%d_%t_%s_%p_bak0' ;
sql 'alter system archive log current';
backup format '/oracle/backup/arch_%T_%d_%t_%s_%p_bak0' archivelog all delete input;
backup spfile include current controlfile format '/oracle/backup/spfile_controlfile_%T_%d_%t_%s_%p_bak0';
release channel c1;
release channel c2;
release channel c3;
}

#########restore&&recover#####################

rman nocatalog target /


RMAN>startup nomount;

###[恢復引數檔案]########
RMAN>
RMAN>
恢復引數檔案指令碼:
run
{
 restore spfile from '/oracle/backup/spfile_controlfile_20120809_CCDB_790856516_27_1_bak0';
}

##########恢復控制檔案###############
RMAN>
恢復控制檔案指令碼:
run{
restore controlfile from '/oracle/backup/spfile_controlfile_20120809_CCDB_790856510_26_1_bak0';
}


特別注意:
RMAN>
1:恢復控制檔案成功,注意控制檔案的輸出位置;
2:此時如果mount ,則由於控制檔案的位置不同造成失敗
3:修改引數檔案,指定控制檔案的位置




#################資料檔案RESTORE######################

RMAN> list backup of database;

可以看到有7個資料檔案,由於源資料庫採用ASM儲存,需要進行轉儲resotre
run{
set newname for datafile 1 to '/oracle/oradata/ccdb/system01.dbf';
set newname for datafile 2 to '/oracle/oradata/ccdb/sysaux01.dbf';
set newname for datafile 3 to '/oracle/oradata/ccdb/undotbs01.dbf';
set newname for datafile 4 to '/oracle/oradata/ccdb/users01.dbf';
set newname for datafile 5 to '/oracle/oradata/ccdb/system03.dbf';
set newname for datafile 6 to '/oracle/oradata/ccdb/system02.dbf';
set newname for datafile 7 to '/oracle/oradata/ccdb/test.dbf';
restore database;
switch datafile all;
}

本機是用檔案系統:

所以不用轉儲
方法1:
run{
startup force mount;
restore datafile 1;
recover datafile 1;
restore datafile 2;
recover datafile 2;
restore datafile 3;
recover datafile 3;
restore datafile 4;
recover datafile 4;
restore datafile 5;
recover datafile 5;
restore datafile 6;
recover datafile 6;
restore datafile 7;
recover datafile 7;
sql 'alter database open';
}
方法2:
run{
startup force mount;
restore database;
recover database;
sql 'alter database open';
}


總結:
資料庫最重要的是資料,資料最重要最安全的是定期做備份!資料重於一切;備份高於一切;恢復保障資料安全有效!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14661773/viewspace-740485/,如需轉載,請註明出處,否則將追究法律責任。

相關文章