Some useful RMAN comands for busy DBAs

Save rman output to text
===========================
RMAN> spool log to '/tmp/rmanbackuplog.f';
RMAN> backup datafile 1;
spool log RMAN> off;
Spooling for log turned off


RMAN> host 'ls -ltr /tmp/rman*'
2> ;
-rw-r--r-- 1 oracle oinstall 961 May 10 15:47 /tmp/rmanbackuplog.f
host command complete
RMAN> host 'cat /tmp/rmanbackuplog.f'
2> ;


Restore / Recovery:  Determine what needs to restore and validation
===================================================================


select file#, status, error, recover from v$datafile_header;If the REC column shows a YES or null value, it indicates that you have a problem.


select file#, error from v$recover_file;This shows the files need mediate recovery


select file#, status, checkpoint_change#, to_char(checkpoint_time, 'dd-mon-rrrr hh24:mi:ss')
from v$datafile_header;
 

RMAN>  restore tablespace system preview;
RMAN> host 'cat /tmp/preview.log';
restore database validate;
restore datafile 1 validate;
Restore datafiles to non-default locations
RMAN > connect target /
run {
startup mount
set newname for datafile 10 to '+DG_DATA02';
restore tablespace DATA02
switch datafile all; ==> this will update repository with new datafile location
recover tablespace DATA02;
alter database open;
}


Incomplete recovery:  when performing incomplete database recovery, all of the checkpoint SCNs for all online datafiles must be synchroized before you can open the database with alter database open resetlogs command.  You can view the datafile header SCNs and the status of each datafile via this SQL query:


select file#, status, checkpoint_change#, to_char(checkpoint_time, 'dd-mon-rrrr hh24:mi:ss')
from v$datafile_header;



RMAN> recover corruption list;


To be continued..

No comments:

Post a Comment