You are on page 1of 7

RMAN BACKUP SCENARIOUS

Full Database Restore


$ORACLE_HOME/bin/rman target / nocatalog
RMAN> shutdown abort;
RMAN> startup mount;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open;
database opened
Tablespace Restore (online)
$ORACLE_HOME/bin/rman target / nocatalog
RMAN> sql alter tablespace users offline;
RMAN> restore tablespace users;
RMAN> recover tablespace users;
RMAN> sql alter tablespace users online;
* A SYSTEM tablespace cannot be recovered with the database online.
Tablespace Restore (offline)
$ORACLE_HOME/bin/rman target / nocatalog
RMAN> shutdown abort;
RMAN> startup mount;
RMAN> restore tablespace users;

RMAN> recover tablespace users;


RMAN> alter database open;
database opened
Restoring a Specific Datafile
$ORACLE_HOME/bin/rman target / nocatalog
RMAN> shutdown abort;
RMAN> startup mount;
RMAN> restore datafile /oradata/DB1/dbf/users01.dbf;
RMAN> recover datafile /oradata/DB1/dbf/users01.dbf;
RMAN> alter database open;
database opened
Control File Restoration
Prerequisite: In your rman backup directory determine the latest control file backup.
Default Format: c-nnnnnnnnnn-nnnnnnnn-nn
$ORACLE_HOME/bin/rman target / nocatalog
RMAN> shutdown abort;
RMAN> startup nomount;
RMAN> set dbid = 1184749195
RMAN> restore controlfile from /oradata/DB1/rman/c-1184749195-20060626-02
RMAN> alter database mount;
RMAN> restore database;
RMAN> recover database;

RMAN> alter database open resetlogs;


database opened
Database Point-In-Time-Recovery (PITR)
Also known as time-based incomplete recovery.
$ORACLE_HOME/bin/rman target / nocatalog
RMAN> shutdown abort;
RMAN> startup mount;
RMAN> restore database until time to_date(09/03/07 13:00:00, MM/DD/YY
HH24:MI:SS);
RMAN> recover database until time to_date(09/03/07 13:00:00, MM/DD/YY
HH24:MI:SS);
RMAN> alter database open resetlogs;
database opened
* Make sure you perform a full backup after this operation!
Restore to Another System
Prerequisites
Ideally ensure destination system configured exactly like source.
Same OS version and patch level.
Same drives (C:, D:, S: etc.).
CPU and RAM same or better.
The same version of Oracle is installed on the target system as the source.
Ensure the ORACLE_HOME and ORACLE_SID environment variables are set.
Ensure the listener is running.

Copy RMAN backupset files to the destination system rman directory.


If Windows:
Create the password file.
orapwd file=orapwDB1 password=mypassword
Creates the file %ORACLE_HOME%\dbs\orapwDB1
Copy %ORACLE_HOME%\dbs\orapwDB1 to %ORACLE_HOME%\database.
In some instances of a restore like this it may look for the file here.
Create or start the Windows database instance service.
oradim -new -sid DB1 -intpwd mypassword -startmode MANUAL
Creates the file: %ORACLE_HOME%\database\PWDDB1.ORA
Ensure the drive\path to the admin (adump,bdump,cdump,udump), data and redo directories on
the source and destination systems are identical.
Example:
Admin Dump Directories
mkdir C:\oracle\product\10.2.0\admin
mkdir C:\oracle\product\10.2.0\admin\DB1
mkdir C:\oracle\product\10.2.0\admin\DB1\adump
mkdir C:\oracle\product\10.2.0\admin\DB1\bdump
mkdir C:\oracle\product\10.2.0\admin\DB1\cdump
mkdir C:\oracle\product\10.2.0\admin\DB1\udump
Data Directories
mkdir D:\oradata

mkdir D:\oradata\DB1
Redo and Archive Log Directories
mkdir D:\oradata\DB1\recovery1
mkdir D:\oradata\DB1\recovery2
Procedure
Restore SPFILE and Control File
%ORACLE_HOME%\bin\rman target / nocatalog
RMAN> set dbid 161080442
RMAN> startup nomount;
Creates the file: %ORACLE_HOME%\database\hc_db1.dat
RMAN> restore spfile from R:\rman\C-161080442-20080313-00;
Creates the file: %ORACLE_HOME%\database\SPFILEDB1.ORA
RMAN> startup force nomount
RMAN> restore controlfile from R:\rman\C-161080442-20080313-00;
RMAN> shutdown immediate
RMAN> exit
Restore and Recover the Data
%ORACLE_HOME%\bin\rman target / nocatalog
RMAN> startup mount;
RMAN> restore database;
For a large database this step may take some time.
RMAN> recover database;

If you do not have\need the very last log(s) you can disregard any error messages.
ORA-00310: archived log contains sequence 100; sequence 101 required
RMAN> alter database open resetlogs;
database opened

RMAN Archivelog List Commands


0 Comments Published by nag April 11th, 2013 in RMAN

RMAN Archivelog List Commands


RMAN>list archivelog all;
RMAN>list copy of archivelog until time SYSDATE-10;
RMAN>list copy of archivelog from time SYSDATE-10
RMAN>list copy of archivelog from time SYSDATE-10 until time SYSDATE-2;
RMAN>list copy of archivelog from sequence 1000;
RMAN>list copy of archivelog until sequence 1500;
RMAN>list copy of archivelog from sequence 1000 until sequence 1500;
Archivelog Delete Commands
RMAN>delete archivelog all completed before sysdate -1; will delete one day previous
archives
RMAN>delete archivelog all;
RMAN>delete archivelog until time SYSDATE-10;
RMAN>delete archivelog from time SYSDATE-10
RMAN>delete archivelog from time SYSDATE-10 until time SYSDATE-2;
RMAN>delete archivelog from sequence 1000;
RMAN>delete archivelog until sequence 1500;
RMAN>delete archivelog from sequence 1000 until sequence 1500;

Oracle How to purge old RMAN backups


Oracle How to purge old RMAN backups
Do not use rm to remove files. You must do it via RMAN.
$ export NLS_DATE_FORMAT=DD-MM-YY HH24:MI

$ rman target / NOCATALOG


RMAN > crosscheck backupset;
This command will verify whether backup file is still on media.
If it is unavailable, RMAN will mark it as UNAVAILABLE or EXPIRED.
RAMN > delete expired backupset;
or
RMAN > delete expired backup;
Note : If you manually rename or zip RMAN backup files, you must manually remove it from
disk since RMAN
does not recognize them.
RMAN > report obsolete;
The command lists all backups rendered obsolete based on rentention policy.
Current Retention Policy is Recovery WINDOW OF 30 DAYS.
RMAN > delete obsolete;
RMAN > list backup summary;
It will show all backupset info kept in RMAN repository.
If you want to see what RMAN keeps in each backupset, run list backupset N where N is
Backupset ID.
RMAN > delete backupset N;
or
RMAN > delete backupset; (to delete all backups)
Once fair amount of space is reclaimed, do full backup.
Not sure how much full back space is needed but not less than 20G.
RMAN > backup database;
RMAN > list backup;
Full backup may have more than one backupset.
Look for last backupsets. It will list backup db files.
RMAN > delete obsolete;
Rerun this command to delete unwanted existing backupsets (if have) after completed full
backup.

You might also like