Basic RMAN command
Rman> show all – displays everything
Rman> list backup – displays a list of
backups
Some useful Rman configuration
Rman > CONFIGURE CONTROLFILE AUTOBACKUP on;
Rman > CONFIGURE CHANNEL DEVICE TYPE DISK
FORMAT ‘C:\oracle\backup\ora_df%t_s%s_s%p';
Backing up using Rman. Some basic commands and options
Rman > backup database;
Rman > backup incremental level 0 database;
Rman > backup tablspace 'users';
Rman > backup current controlfile;
Here is an example of full recovery on bare system (meaning you lost everything! Or you are re-creating on another machine). Usually, if the spfile and controlfile is not missing, you can simply do a "restore database", "recover database" process
Set ORACLE_SID=mydb
%ORACLE_HOME%\bin\rman target mydb/password
Rman> startup nomount;
Rman> set DBID =;
Rman> restore spfile from autobackup;
Rman> restore controlfile from autobackup;
Rman> alter database mount;
Rman> restore database;
Rman> recover database;
Rman> alter database open resetlogs;
Note : I have some problem with the control files . I need to copy the files from %oracle_home%\database to %oracle_home%\oradata and copy the pwd password file over to to make it work. Use "startup force mount" if you are installing on a fresh machine. I wonder if anyone have similar problems?
Rman> report obsolete;
Rman> delete obsolete noprompt;
Eg : backup all database and archive log. Delete all obsolete backup after backup is done
Rman> backup device type disk database;
Rman> backup device type disk archivelog all not
backed up delete all input;
Rman> delete noprompt obsolete device type disk;
Unable to find controlfile autobackup (Rman-06172)
If you use a different directory/format for controlfile autobackup you can set that format in the recovery script
set DBID=8267167
set controlfile autobackup format for device type disk to
'e:\dev\back\%F';
restore controlfile from
autobackup;
Otherwise, move them to Oracle_Home\database
Samples scripts
Backup incremental 1,2,..x
runRestore database
{ allocate
channel d1 type disk;
backup incremental
level=0 cumulative database format 'c:\ORACLE\BACKUP\ch12\db_%d_%s_%p_%t'
tag = 'whole_inc0';}
run
{ allocate channel d1 type disk; backup
incremental level = 1 cumulative database
format
'c:\oracle\BACKUP\ch12\db_%d_%s_%p_%t'
tag = 'whole_inc1';}
shutdown abort;
startup mount;
run
{ allocate channel d1 type disk;
restore database;
recover database;}
Duplicate database
connect target sys/practice@practice
connect catalog rman/rman@rcat
connect auxiliary sys/cline@cline
run
{ set until logseq 13 thread 1;
allocate auxiliary channel d1 type disk;
duplicate target database to CLINE;}
alter database open;
Standby database
run { allocate channel d1 type disk;Incomplete recovery
backup incremental level=0 database format
'c:\ORACLE\BACKUP\db_%d_%s_%p_%t'
tag = 'stby_inc0'
include current controlfile for standby;
sql "alter system archive log current";
backup archivelog from time 'sysdate-1/24'
format 'c:\ORACLE\BACKUP\ar_%d_%s_%p_%t';}
run
{ set until time "to_date('11/28/2005 16:00:00','MM/DD/YYYY
HH24:MI:SS')";
shutdown immediate;
startup mount;
allocate channel d1 type disk;
restore database;
recover database;
alter database open resetlogs;}
Some Rman links
http://www.pafumi.net/rman.htm
No comments:
Post a Comment