Run { Allocate channel d1 type disk. Backup as compressed backupset(可选的) incremental level 0 format ‘d:\backup\db_%d_%s_%p_%t’ database. Release channel d1. Alter database open. }
Run { Set until time “TO_DATE(‘08/07/2007 12:00:00’, ‘MM/DD/YYYY HH24:MI:SS’)”. Shutdown immediate. Startup mount. Allocate channel d1 type disk. Restore database. Recover database. Release channel d1. Alter database open resetlogs. } 当数据库被恢复后,会通过Alter database open resetlogs将重置日志,此时,新的控制文件会将以前的备份信息丢失,这样数据库就不能在用不完全恢复去恢复到‘08/07/2007 12:00:00之前的某个时间点。有一个办法就是首先恢复控制文件到先前的某个版本,然后再恢复数据库。
建议不完全恢复都采用这种做法。先恢复控制文件,再恢复数据文件。 Shutdown abort. Startup nomount. Run { Allocate channel d1 type disk. Restore controlfile from ‘d:\backup\CTL_TEST_0_1_6555’. Release channel d1 . Alter database mount. RMAN> run { set until time "TO_DATE(’08/08/2007 10:30:00’,’MM/DD/YYYY HH24:MI:SS’)". shutdown immediate. startup mount. allocate channel d1 type disk. restore database. recover database. release channel d1. alter database open resetlogs. }