Backup recovery case in rman and rman backup recovery case
Backup
RMAN> show all;
RMAN> configure controlfile autobackup on; Set automatic backup of Control Files
RMAN> backup database format = '/home/oracle/myrman/prod _ % s. Bak' filesperset 3;
RMAN> list backup;
1. Simulate system01.dbf corruption
Rm/u01/oradata/prod/system01.dbf
Startup froce
Solution:
Run {
Startup force mount;
Restore datafile 1;
Recover datafile 1;
Alter database open;
}
2. Simulate users01.dbf corruption
Rm/u01/oradata/prod/users01.dbf
Alter system flush buffer_cache;
Solution:
Run {
SQL 'alter tablespace users offline ';
Restore tablespace users;
Recover tablespace users;
SQL 'alter tablespace users online ';
}
3. The created tablespace is deleted by mistake.
Create tablespace abcd datafile '/u01/oradata/prod/abcd01.dbf' size 5 m;
Create table scott. t2 (id int) tablespace abcd;
Insert into scott. t2 values (1 );
Commit;
Select * from scott. t2;
Rm/u01/oradata/prod/abcd01.dbf
Alter system flush buffer_cache;
Solution:
Run {
SQL 'alter database datafile 7 offline ';
Restore datafile 7;
Recover datafile 7;
SQL 'alter database datafile 7 online ';
}
Select * from scott. t2;
Drop tablespace abcd including contents and datafiles;
4.
Incomplete recovery
Restore table Truncation
Select * from scott. t1;
Select sysdate from dual; record time can also be the log mining time
Truncate table scott. t1;
Solution:
Run {
Startup force mount;
Set until time 'xxxx ';
Restore database;
Recover database;
Alter database open resetlogs;
}
5.
2.
Delete the spfile by mistake
Shutdown abort
Rm spfileprod. ora
Solution:
Rman target/
RMAN> startup nomount;
$ Ll/u01/flash_recovery_area/prod/autobackup/2013_01_16 /..
RMAN> restore spfile form '/u01/flash_recovery_area/prod/autobackup/2013_01_16 /..';
6.
Accidentally delete a tablespace
Shutdown abort
Rm *. ctl
Rm *. dbf
Solution:
Run {
Startup force nomount;
Set dbid = 3416564781;
Restore controlfile from autobackup until time 'xxxx ';
Alter database mount;
Restore database;
Recover database until time 'xxxx ';
Alter database open resetlogs;
}
Shutdown immediate
Startup nomount
Restroe controlfile from '';
Alter database mount;
Restroe database until time '';
Recover database until time '';
Alter database open resetlog;
7.
Tablespace time point recovery
Create tablespace defg datafile '/u01/oradata/prod/defg01.dbf' size 5 m;
Create table scott. t2 (c1 date) tablespace defg;
Insert into scott. t2 values (sysdate );
Commit;
Backup tablespace defg format '/u01/myrman/defg _ % s. bak ';
Select sysdate from dual;
Drop table scott. t2 purge;
Solution:
$ Mkdir-p/u01/oradata/prod/auxdata
Recover tablespace abcd until time 'xxxx' auxiliary destination'/u01/oradata/prod/auxdata ';
8.
Delete A Database
Build a spfile File
Rman target/
RMAN> startup nomount;
$ Ll/u01/flash_recovery_area/prod/autobackup/2013_01_16/
RMAN> retore spfile form '/u01/flash_recovery_area/prod/autobackup/2013_01_16 /..';
String spfileprod. ora
Mkdir-p/u01/admin/emrep/adump
Build control files and data files
1. shutdown immediate
2. startup nomount
3. restore the control file and verify restore controlfile from '';
4. alter database mount
5. restore database until time '';
6. recover database until time '';
(
Number of recover database until sequence;
Or
Number of recover database until scn;
)
7. alter database open resetlogs;