Ebenze’s Weblog

Just another WordPress.com weblog

RMAN Command reference

Posted by ebenze on July 31, 2008

===================================
R-M-A-N =
===================================


Connect:
$rman target /
$rman nocatalog target /
$rman nocatalog target sys/aziz@JKTDB2
$rman target sys/aziz@JKTDB2

RMAN> shutdown;
RMAN> shutdown immediate;

RMAN> startup mount; >>startup an instance and mounting database
RMAN> startup nomout; >>startup an instance without mounting database
RMAN> startup restrict; >>restricting access to an instance at startup
RMAN> ALTER SYSTEM DISABLE RESTRICTED SESSION; >>disable the restricted session
RMAN> STARTUP FORCE; >>forcing an instance to start
RMAN> STARTUP OPEN RECOVER >>Starting an Instance, Mounting a Database,
and Starting Complete Media Recovery
RMAN> connect target sys/aziz@jktdb2;
RMAN> startup mount;
RMAN> register database; >>register target database to recovery catalog
RMAN> reset database; >>create new database incarnation record in the

recovery catalog
RMAN> backup database;
RMAN> backup current controlfile;
RMAN> backup database plus archivelog;
RMAN> backup archivelog all;
RMAN> list backup; >>list all file that was backed up
RMAN> list backup summary;
RMAN> restore database;
RMAN> restore archivelog all;
RMAN> recover database;
RMAN> restore datafile ‘C:\ORACLE\ORADATA\JKTDB2\USERS01.DBF’;
RMAN> recover datafile ‘C:\ORACLE\ORADATA\JKTDB2\USERS01.DBF’;
RMAN> Recover database until cancel using backup controlfile;
RMAN> Alter database open resetlogs;
RMAN> allocate channel for maintenance type disk;
RMAN> crosscheck backup of database;
RMAN> delete expired backup of database;
RMAN> crosscheck backup of archivelog all;
RMAN> delete expired backup of archivelog all;
RMAN> change archivelog all crosscheck;
RMAN> resync catalog;
RMAN> crosscheck backup of archivelog all;
RMAN> sql ‘alter tablespace USERS offline immediate’;
RMAN> recover tablespace USERS;
RMAN> sql ‘alter tablespace USERS online’;

—————————————————————
configure =
—————————————————————
RMAN>configure default device type to ’sbt_tape’; >>to tape
RMAN>configure default device type to DISK; >>to disk
rman>configure controlfile autobackup format for device type ’sbt_tape’ to ‘%F’;
RMAN>configure controlfile autobackup on;
RMAN>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

RMAN>CONFIGURE RETENTION POLICY TO REDUNDANCY 3; >>Retain three backups of each datafile:
RMAN> resync catalog;

—————————————————————
Restore & Recover The Whole Database=
—————————————————————
run {
shutdown immediate; # use abort if this fails
startup mount;
restore database;
recover database;
alter database open;
}
—————————————————————-
Restore & Recover A Subset Of The Database
A subset of the database can be restored in a similar fashion:
—————————————————————-
run {
sql ‘ALTER TABLESPACE users OFFLINE IMMEDIATE’;
restore tablespace users;
recover tablespace users;
sql ‘ALTER TABLESPACE users ONLINE’;
}
—————————————————————–
SAMPLE RMAN RUN BLOCK (as file:backup_full.rman)

run {
allocate channel d1 type disk;
backup full database format ’/export/rman/rman_%n_%T_%s_%p.bus’;
}

then run it :
$ rman nocatalog target / \
> cmdfile=’backup_full.rman’ log=’/export/rman/rman.log’
RMAN> 2> 3> 4> 5>
—————————————————————–
Crosscheck backupset:
RMAN> allocate channel for maintenance type ’sbt_tape’;
RMAN> crosscheck backupset of database;

Delete expired backups:
RMAN> allocate channel for maintenance type ’sbt_tape’;
RMAN> delete expired backupset of database;
—————————————————————–

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>