For taking HOT BACKUP database we have to first make your database into ARCHIVE mode.
COLD BACKUP:
Go for it when the database is off.And most important thing is to make your database into NOARCHIVE mode if it is in ARCHIVE mode by using the command ALTER DATABASE NOARCHIVELOG.
Here the copy of online redo log files from one position to another position cann't be possible.
To configure RMAN to write control file backups to any directory: lets for example I want to put in my 'D' drive "backup " directory.
( %F will generate a unique filename)
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'd:/backup/%F'; and press enter.
NOTE:
By default, the initial format is %F for all devices. Any default format string specified with CONFIGURE must include the %F substitution variable (see BACKUP). This variable translates into c-IIIIIIIIII-YYYYMMDD-QQ, where:
Now we can check your directory i.e in flash_recovery ---> backup folder ,you will see the backup data files are present and in C:/backup directory the controlfile and spfile are get stored.
Now ,you want to restore the database.
RMAN> shutdown immediate; (I guess you know what is shutdown immediate means.(Roll back all active transaction and disconnected all connected users.)
RMAN> exit;
RMAN> restore database;
COLD BACKUP:
Go for it when the database is off.And most important thing is to make your database into NOARCHIVE mode if it is in ARCHIVE mode by using the command ALTER DATABASE NOARCHIVELOG.
Here the copy of online redo log files from one position to another position cann't be possible.
SQL*Plus: Release 10.2.0.4.0 - Production on Sat Nov 8 23:25:43 2008
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Enter user-name: sqlplus / as sysdba (OS Authentication)
Connected to an idle instance.
Now you are in the sqlplus environment.
TO make the database into he cold backup you have to turn the database into
the NOARCHIVELOG mode.
Below are the steps to follow:
sql> shutdown immediate;
sql> startup mount;
sql> alter database noarchivelog;
sql> alter database open;
Now, check whether your database is in which mode by executing the
below code in your sql environment.
sql> select log_mode from v$database;
output should be: NOARCHIVEMODE
So leave it , whenever we will talk about the COLDBACKUP we will
discuss more about it.
NOW, concentrate on making the HOT BACKUP.
to do the HOTBACKUP we have to follow the same
procedure as in the COLD BACKUp with some minor changes.
steps to follow:
sql> shutdown immediate;
sql> startup mount;
sql> alter database archivelog;
sql> alter database open;
Now the real journey begins
Now you are using ORACLE11g R12 you have RMAN installed automatically
in your system because it is embedded with the
oracle installation.
open your RMAN by writing just'rman' in the run box and you will
directed to rman prompt(a COMMAND LINE INTERFACE)
RMAN> Connect target / // it will connect to the target database.
NOWRMAN> show all;
Shows all parameters.
RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/9.2.0/dbs/snapcf_TARGDB.f'; # default
You have to make CONTROLFILE AUTOBACKUP ON (Configure RMAN to back up the control file after each backup)
By default, RMAN automatically names control file backups and stores them in the flash recovery area.
To configure RMAN to write control file backups to any directory: lets for example I want to put in my 'D' drive "backup " directory.
( %F will generate a unique filename)
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'd:/backup/%F'; and press enter.
NOTE:
By default, the initial format is %F for all devices. Any default format string specified with CONFIGURE must include the %F substitution variable (see BACKUP). This variable translates into c-IIIIIIIIII-YYYYMMDD-QQ, where:
- IIIIIIIIII - stands for the DBID. (The DBID is printed in decimal so that it can be easily associated with the target database.
- YYYYMMDD - is a time stamp in the Gregorian calendar of the day the backup is generated.
- QQ - is the sequence in hexadecimal number that starts with 00 and has a maximum of 'FF' (256).
RMAN> backup database; Starting backup at 13-MAY-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=434 devtype=DISK channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/u02/oradata/orcl/system01.dbf input datafile fno=00003 name=/u02/oradata/orc/sysaux01.dbf input datafile fno=00002 name=/u02/oradata/orcl/undotbs01.dbf input datafile fno=00004 name=/u02/oradata/orc/test_db1.dbf channel ORA_DISK_1: starting piece 1 at 13-may-13 channel ORA_DISK_1: finished piece 1 at 13-may-13 piece handle=/u01/app/oracle/flash_recovery_area/DPROD/backupset/2006_09_13/o1_mf_nnndf_TAG20060913T103349_2 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25 Finished backup at 13-may-13 Starting Control File and SPFILE Autobackup at 13-may-13 piece handle=D/backup/C_601036454_2jjj8px2_ comment=NONE Finished Control File and SPFILE Autobackup at 13-may-13
Now we can check your directory i.e in flash_recovery ---> backup folder ,you will see the backup data files are present and in C:/backup directory the controlfile and spfile are get stored.
Now ,you want to restore the database.
RMAN> shutdown immediate; (I guess you know what is shutdown immediate means.(Roll back all active transaction and disconnected all connected users.)
RMAN> exit;
Now again open the RMAN as i said in above procedure and connected to target database.
Note :
To check out whether all your control file and redo file are get restored in their original position or not,
what you have to do is, manually you have to delete all the file that is present in /oradata/orcl directory(talking about oracle 11g R2)
(better make a back of those files in another drive so that if any case any problem happens ,you can take those files once again and keep it in
.oradata/orcl folder)
RMAN> connected target /
RMAN> startup nomount; //because to restore the control file (nomount,mount and open concept)
Nomount: Nothing gets read out only the instance gets started without mount and open.
RMAN>select spfile from 'd:/backup/C_601036454_2jjfsdfdsfj8px2_';
RMAN> select controlfile from 'path to your directory where the control files are get
stored while at the time of backing up the database.
here
RMAN>select controlfile from 'd:/backup/C_601036454_2jjj8px2_';
Now check the orcl directory your control files are get restored. so one step completed.
step2. for restoring the data files.
RMAN> alter database mount;
RMAN> restore database;
check the orcl directory your data files are get restored.
RMAN> recover database;
Here you might be get an error like:
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 11/04/2009 16:11:16 RMAN-06054: media recovery requesting unknown log: thread 1 seq 1234 lowscn 83314466
Reason: RMAN cann't find the online redo logfiles.
Oracle will restore your database. It will also automatically recover the archived redo logs for you, so you don't have to worry about it.
But it's a incomplete recovery(for that reason only we have used RMAN> alter database open resetlogs; below)
SOLUTION for this error is to :
RMAN> recover database until cancel;
or
RMAN> alter database open resetlogs; ( I preferred this one)
// here all the redo log files are get restored in the original directory)
Thanks....hope you find some interesting ..... Have a good day..