For beginners and non, rman is one of the most obscure Oracle tools, but in real ity it is based

on quite simple principles. It is true, though, that a restorati on can be distructive for a database. Why is rman dangerous? rman is dangerous because it works at the database physical level; to understand why, let's say that rman is not "too" different from WinZip. Since everybody kn ows WinZip, it will probably be easier to understand rman. Is WinZip dangerous? The creation of a zip archive is not dangerous, unless you choose the same name for the output file, or the archive is so big that you fill a device or the temp orary directory etc. The same thing can be said about rman: taking an rman backu p cannot be dangerous (unless you stop the database, or close it intentionally) and you don't overwrite previous backups (you can prevent it). rman creates a compressed backup of the physical database files, including contr olfiles, datafiles, archived logs and stores them somewhere. This somewhere can be a disk (like WinZip) or a tape. Therefore, the first important point to remember is: rman creates compressed backups of the physical database; if you prefer, rman zi ps the database, entirely or not. Is Unzip dangerous? Unzip, on the other hand, can be very dangerous. The risk is overwriting files t hat should not be overwritten and, therefore, losing important content. The very same applies to rman restores: since they overwrite database files, you should know whether this is the right decision because, otherwise, you may lose your da ta. This is the main difference between an import and an rman restoration: an rm an restoration (restore) overwrites one or more datafiles; this means WATCH OUT. Our first rman backup The only requirements for taking simple, useful rman backups are two: * You database is in archivelog mode * You have enough disk space somewhere On our Windows 2000 workstation we open a CMD window and type the following few lines: E:\>rman target / Recovery Manager: Release 9.2.0.1.0 - Production Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. connected to target database: ARK9201 (DBID=3564144589) run { allocate channel t1 type disk; backup database format 'E:\RMAN_BACKUPS\ARK9201\%d_%u_%s'; release channel t1; } using target database controlfile instead of recovery catalog allocated channel: t1 channel t1: sid=9 devtype=DISK Starting backup at 10-DEC-04 channel t1: starting full datafile backupset channel t1: specifying datafile(s) in backupset including current SPFILE in backupset including current controlfile in backupset released channel: t1

Database altered. 4> release channel t1. 3> backup database format 'E:\RMAN_BACKUPS\ARK9201\%d_%u_%s'.Production Copyright (c) 1995. All rights reserved. SQL> shutdown immediate Database closed. ORACLE instance shut down. SQL> startup mount ORACLE instance started. Database altered.RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03009: failure of backup command on t1 channel at 12/10/2004 14:28:50 ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode As we said.0 .2. of course.0. SQL> alter database open. 5> } allocated channel: t1 channel t1: sid=12 devtype=DISK Starting backup at 26-DEC-04 channel t1: starting full datafile backupset channel t1: specifying datafile(s) in backupset including current SPFILE in backupset including current controlfile in backupset input datafile fno=00001 name=E:\ORACLE\ORADATA\ARK920\SYSTEM01. Backups are gold and shoud be kept on a dedicated device. Oracle Corporation.DBF . A separate articles explains why it must be so. SQL> alter database archivelog.1. connected to target database: ARK9201 (DBID=3564144589) RMAN> run { 2> allocate channel t1 type disk. the database must be in archive mode if we want to backup open datab ases. Let's now repeat the operation having put the database in archive mode Choosing C:\Temp as directory for the backup is. a very bad idea.DBF input datafile fno=00002 name=E:\ORACLE\ORADATA\ARK920\UNDOTBS01. a good name could be E:\RMAN_BACKU PS\SID E:\>rman target / Recovery Manager: Release 9. Database dismounted. 2002. Total System Global Area 135338868 bytes Fixed Size 453492 bytes Variable Size 109051904 bytes Database Buffers 25165824 bytes Redo Buffers 667648 bytes Database mounted. because it is not so obvio us.

936 ARK920_03G8KC6G_3 Our first archive backup Taking only the database backup is not enough. 5> } allocated channel: t1 channel t1: sid=12 devtype=DISK Starting backup at 26-DEC-04 current log archived channel t1: starting archive log backupset channel t1: specifying archive log(s) in backup set input archive log thread=1 sequence=77 recid=1 stamp=545945036 input archive log thread=1 sequence=78 recid=2 stamp=545945039 input archive log thread=1 sequence=79 recid=3 stamp=545945099 channel t1: starting piece 1 at 26-DEC-04 channel t1: finished piece 1 at 26-DEC-04 piece handle=C:\RMAN_BACKUPS\ARK9201\ARCH_ARK920_04G8KTGL_4 comment=NONE channel t1: backup set complete.DBF channel t1: starting piece 1 at 26-DEC-04 channel t1: finished piece 1 at 26-DEC-04 piece handle=E:\RMAN_BACKUPS\ARK9201\ARK920_03G8KC6G_3 comment=NONE channel t1: backup set complete.DBF input datafile fno=00005 name=E:\ORACLE\ORADATA\ARK920\INDX01.001 recid=2 stamp=545945039 archive log filename=E:\ORA920\RDBMS\ARC00079.001 recid=1 stamp=545945036 archive log filename=E:\ORA920\RDBMS\ARC00078.001 recid=3 stamp=545945099 Finished backup at 26-DEC-04 released channel: t1 .471.DBF input datafile fno=00008 name=E:\ORACLE\ORADATA\ARK920\USERS01. 12/26/2004 02:44p 418. 3> backup archivelog all delete input format 'C:\RMAN_BACKUPS\ARK9201\arch_%d_%u _%s'. elapsed time: 00:00:37 channel t1: deleting archive log(s) archive log filename=E:\ORA920\RDBMS\ARC00077.DBF input datafile fno=00009 name=E:\ORACLE\ORADATA\ARK920\XDB01. We must take a backup of the archived log as well.DBF input datafile fno=00003 name=E:\ORACLE\ORADATA\ARK920\DRSYS01.DBF input datafile fno=00007 name=E:\ORACLE\ORADATA\ARK920\TOOLS01.. elapsed time: 00:25:58 Finished backup at 26-DEC-04 released channel: t1 The resulting backup file(s) are in our case dir c:\rman_backups\ark9201 Volume in drive C is 80-01-14A2 Volume Serial Number is 64DA-0BF7 Directory of c:\rman_backups\ark9201 12/26/2004 02:29p . and the command is very similar RMAN> run { 2> allocate channel t1 type disk. 4> release channel t1. 12/26/2004 02:29p .input datafile fno=00004 name=E:\ORACLE\ORADATA\ARK920\EXAMPLE01.DBF input datafile fno=00006 name=E:\ORACLE\ORADATA\ARK920\ODM01. for reasons that will be clear la ter.

dbf input datafile fno=00005 name=/u01/oradata/ORA920/oem_repository.1/dbs/c-2554142925-20050118-00 comment=NONE Finished Control File Autobackup at 14:31:22 18-jan-2005 released channel: t1 RMAN> host .dbf input datafile fno=00003 name=/u01/oradata/OMF_DATA_ORA920/o1_mf_tools_0ybbwkp7_ .0.2. using an appropriate directory format: RMAN> run { allocate channel t1 type disk.dbf input datafile fno=00002 name=/u02/oradata/ORA920/undo01. 4> release channel t1. 2> backup database format '/u01/oracle/archive/%d_%u_%s'.RMAN> rman on UNIX rman works the same way on a UNIX server. elapsed time: 00:00:05 Finished backup at 14:31:18 18-jan-2005 Starting Control File Autobackup at 14:31:18 18-jan-2005 piece handle=/optware/oracle/9. 2> backup current controlfile format '/u01/oracle/archive/controlf_%d_%u_%s'.dbf input datafile fno=00004 name=/u01/oradata/OMF_DATA_ORA920/o1_mf_tbs_data_0ybcd2 8z_. 3> backup current controlfile format '/u01/oracle/archive/%d_%u_%s'. oracle@edc-se[on pts/4] total 562128 -rw-r----.} using target database controlfile instead of recovery catalog allocated channel: t1 channel t1: sid=26 devtype=DISK Starting backup at 14:29:22 18-jan-2005 channel t1: starting full datafile backupset channel t1: specifying datafile(s) in backupset input datafile fno=00001 name=/u01/oradata/ORA920/system01.1 oracle oracle@edc-se[on pts/4] host command complete Backup the controlfile RMAN> run { allocate channel t1 type disk. elapsed time: 00:01:48 Finished backup at 14:31:11 18-jan-2005 Starting backup at 14:31:11 18-jan-2005 channel t1: starting full datafile backupset channel t1: specifying datafile(s) in backupset including current controlfile in backupset channel t1: starting piece 1 at 14:31:15 18-jan-2005 channel t1: finished piece 1 at 14:31:18 18-jan-2005 piece handle=/u01/oracle/archive/ORA920_02gah0th_2 comment=NONE channel t1: backup set complete.1 oracle -rw-r----.dbf channel t1: starting piece 1 at 14:29:24 18-jan-2005 channel t1: finished piece 1 at 14:31:10 18-jan-2005 piece handle=/u01/oracle/archive/ORA920_01gah0q3_1 comment=NONE channel t1: backup set complete. ls -ltr /u01/oracle/archive/ dba dba exit 282476544 Jan 18 14:31 ORA920_01gah0q3_1 5177344 Jan 18 14:31 ORA920_02gah0th_2 .

0. 3> release channel t1.3> release channel t1.} allocated channel: t1 channel t1: sid=26 devtype=DISK Starting backup at 14:42:00 18-jan-2005 current log archived channel t1: starting archive log backupset channel t1: specifying archive log(s) in backup set input archive log thread=1 sequence=9 recid=1 stamp=547477014 input archive log thread=1 sequence=10 recid=2 stamp=547562627 input archive log thread=1 sequence=11 recid=3 stamp=547562680 input archive log thread=1 sequence=12 recid=4 stamp=547580133 input archive log thread=1 sequence=13 recid=5 stamp=547623518 input archive log thread=1 sequence=14 recid=6 stamp=547744760 input archive log thread=1 sequence=15 recid=7 stamp=547865707 input archive log thread=1 sequence=16 recid=8 stamp=547915324 channel t1: starting piece 1 at 14:42:08 18-jan-2005 channel t1: finished piece 1 at 14:43:03 18-jan-2005 piece handle=/u01/oracle/archive/archive_ORA920_06gah1hv_6 comment=NONE channel t1: backup set complete.} allocated channel: t1 channel t1: sid=26 devtype=DISK Starting backup at 14:33:59 18-jan-2005 channel t1: starting full datafile backupset channel t1: specifying datafile(s) in backupset including current controlfile in backupset channel t1: starting piece 1 at 14:34:00 18-jan-2005 channel t1: finished piece 1 at 14:34:03 18-jan-2005 piece handle=/u01/oracle/archive/controlf_ORA920_04gah12n_4 comment=NONE channel t1: backup set complete.2.1/dbs/c-2554142925-20050118-01 comment=NONE Finished Control File Autobackup at 14:34:07 18-jan-2005 released channel: t1 Here is a backup of archived log files RMAN> run { allocate channel t1 type disk. elapsed time: 00:00:56 channel t1: deleting archive log(s) archive log filename=/optware/oracle/admin/ORA920/arch/ORA920_1_9. elapsed time: 00:00:04 Finished backup at 14:34:03 18-jan-2005 Starting Control File Autobackup at 14:34:03 18-jan-2005 piece handle=/optware/oracle/9.arc recid=1 st amp=547477014 archive log filename=/optware/oracle/admin/ORA920/arch/ORA920_1_10.arc recid=4 s tamp=547580133 archive log filename=/optware/oracle/admin/ORA920/arch/ORA920_1_13.arc recid=6 s tamp=547744760 .arc recid=2 s tamp=547562627 archive log filename=/optware/oracle/admin/ORA920/arch/ORA920_1_11.arc recid=3 s tamp=547562680 archive log filename=/optware/oracle/admin/ORA920/arch/ORA920_1_12.arc recid=5 s tamp=547623518 archive log filename=/optware/oracle/admin/ORA920/arch/ORA920_1_14. 2> backup archivelog all format '/u01/oracle/archive/archive_%d_%u_%s' delete in put.

RMAN> show 2> all.---------. in your init.----------.0. for example.arc recid=8 s tamp=547915324 Finished backup at 14:43:04 18-jan-2005 Starting Control File Autobackup at 14:43:04 18-jan-2005 piece handle=/optware/oracle/9. # default CONFIGURE BACKUP OPTIMIZATION OFF. This i s the case. # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1.1/dbs/snapcf_ORA92 0..ora In our case the values is . backup archivelog from logseq 12 until logseq 15 thread 1 delete input. # default RMAN> list backupset .2.-. List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------. # default CONFIGURE CONTROLFILE AUTOBACKUP ON.archive log filename=/optware/oracle/admin/ORA920/arch/ORA920_1_15.arc Remember that the name depends on the parameter . # default CONFIGURE MAXSETSIZE TO UNLIMITED. # default CONFIGURE DEVICE TYPE DISK PARALLELISM 1.-.1/dbs/c-2554142925-20050118-02 comment=NONE Finished Control File Autobackup at 14:43:09 18-jan-2005 released channel: t1 The rman clauses from logseq and until logseq Sometimes you will want to backup only certain archived logs and not all. # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1.---. when you ran out of space and you were forced to move t he archived logs on disk onto another directory..---.0.-------------------.2. CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'. RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1.-----------. run { allocate channel dev1 type 'sbt_tape'.---------.arc to ORA920_1_15. } Keeping an eye on the list above.f'.-------------------1 Full 269M DISK 00:01:41 14:31:04 18-jan-2005 BP Key: 1 Status: AVAILABLE Tag: TAG20050118T142923 Piece Name: /u01/oracle/archive/ORA920_01gah0q3_1 List of Datafiles in backup set 1 File LV Type Ckp SCN Ckp Time Name ---.dbf . # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/optware/oracle/9.---1 Full 562946 14:29:24 18-jan-2005 /u01/oradata/ORA920/system01..dbf 2 Full 562946 14:29:24 18-jan-2005 /u02/oradata/ORA920/undo01. # default CONFIGURE DEFAULT DEVICE TYPE TO DISK. because rman will not be able to find the files. In this case the clause "archiv elog all" would give an error. the command would back up the archived redo lo gs from ORA920_1_12..arc recid=7 s tamp=547865707 archive log filename=/optware/oracle/admin/ORA920/arch/ORA920_1_16.

0.----------.-------------------4 Full 4M DISK 00:00:03 14:34:02 18-jan-2005 BP Key: 4 Status: AVAILABLE Tag: TAG20050118T143359 Piece Name: /u01/oracle/archive/controlf_ORA920_04gah12n_4 Controlfile Included: Ckp SCN: 563233 Ckp time: 14:33:59 18-jan-2005 BS Key Type LV Size Device Type Elapsed Time Completion Time ------.---.1/dbs/c-2554142925-20050118-01 Controlfile Included: Ckp SCN: 563233 Ckp time: 14:33:59 18-jan-2005 BS Key Size Device Type Elapsed Time Completion Time ------.-----------.-------------------5 Full 4M DISK 00:00:02 14:34:06 18-jan-2005 BP Key: 5 Status: AVAILABLE Tag: Piece Name: /optware/oracle/9.-------------------6 203M DISK 00:00:56 14:43:03 18-jan-2005 BP Key: 6 Status: AVAILABLE Tag: TAG20050118T144206 Piece Name: /u01/oracle/archive/archive_ORA920_06gah1hv_6 List Thrd ---1 1 1 1 1 1 1 1 of Archived Logs in backup set 6 Seq Low SCN Low Time ------.---------.----------.0.---------.-----------.---------.2.-----------.-.dbf 5 Full 562946 14:29:24 18-jan-2005 /u01/oradata/ORA920/oem_repositor y.---------.1/dbs/c-2554142925-20050118-02 Controlfile Included: Ckp SCN: 563788 Ckp time: 14:43:03 18-jan-2005 .----------.-------------------2 Full 4M DISK 00:00:03 14:31:16 18-jan-2005 BP Key: 2 Status: AVAILABLE Tag: TAG20050118T143112 Piece Name: /u01/oracle/archive/ORA920_02gah0th_2 Controlfile Included: Ckp SCN: 563054 Ckp time: 14:31:13 18-jan-2005 BS Key Type LV Size Device Type Elapsed Time Completion Time ------.---------.----------.-------------------3 Full 4M DISK 00:00:02 14:31:20 18-jan-2005 BP Key: 3 Status: AVAILABLE Tag: Piece Name: /optware/oracle/9.---.3 Full 562946 14:29:24 18-jan-2005 /u01/oradata/OMF_DATA_ORA920/o1_m f_tools_0ybbwkp7_.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------.-----------.-----------.0.----------.---.-.----------.-.2.-----------.---.dbf 4 Full 562946 14:29:24 18-jan-2005 /u01/oradata/OMF_DATA_ORA920/o1_m f_tbs_data_0ybcd28z_.---------.-.1/dbs/c-2554142925-20050118-00 Controlfile Included: Ckp SCN: 563071 Ckp time: 14:31:18 18-jan-2005 BS Key Type LV Size Device Type Elapsed Time Completion Time ------.---.-.-------------------9 118838 12:18:25 13-jan-2005 10 124198 12:56:51 13-jan-2005 11 208951 12:43:38 14-jan-2005 12 209145 12:44:30 14-jan-2005 13 227914 17:35:21 14-jan-2005 14 271564 05:38:29 15-jan-2005 15 392830 15:19:13 16-jan-2005 16 514138 00:55:00 18-jan-2005 Next SCN ---------124198 208951 209145 227914 271564 392830 514138 563727 Next Time --------12:56:51 13-jan-2005 12:43:38 14-jan-2005 12:44:30 14-jan-2005 17:35:21 14-jan-2005 05:38:29 15-jan-2005 15:19:13 16-jan-2005 00:55:00 18-jan-2005 14:42:00 18-jan-2005 BS Key Type LV Size Device Type Elapsed Time Completion Time ------.---------.2.-------------------7 Full 4M DISK 00:00:02 14:43:07 18-jan-2005 BP Key: 7 Status: AVAILABLE Tag: Piece Name: /optware/oracle/9.

little point in taking backups if we don't know whether the y are physically usable. already backed up on datafile 3. already backed up on backup at 15:41:33 21-jan-2005 20:38:51 20:38:51 20:38:51 20:38:51 20:38:51 18-jan-2005 18-jan-2005 18-jan-2005 18-jan-2005 18-jan-2005 released channel: t1 . i. of course. To avoid any r isk the clause not backed up since time can be used.} allocated channel: t1 channel t1: sid=25 devtype=DISK Starting skipping skipping skipping skipping skipping Finished backup at 15:41:31 21-jan-2005 datafile 1.e. This commands makes rman sa ve only the datafiles (or the archived logs) that haven't be backed up for a cer tain span of time and skip the rest. all their blocks are clean.2. 3> release channel t1.RMAN> Are we sure that our backups do not contain corrupted blocks There is.1/dbs/c-2554142925-20050118-01 tag=null param s=NULL channel ORA_DISK_1: validation complete RMAN> validate backupset 4. using channel ORA_DISK_1 channel ORA_DISK_1: starting validation of datafile backupset channel ORA_DISK_1: restored backup piece 1 piece handle=/optware/oracle/9. rman offer the command validate RMAN> validate backupset 6. already backed up on datafile 4. already backed up on datafile 2. 2> backup database format '/u01/oracle/archive/%d_%u_%s' not backed up since ti me 'sysdate -5'. RMAN> run { allocate channel t1 type disk.0. allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=26 devtype=DISK channel ORA_DISK_1: starting validation of archive log backupset channel ORA_DISK_1: restored backup piece 1 piece handle=/u01/oracle/archive/archive_ORA920_06gah1hv_6 tag=TAG20050118T14420 6 params=NULL channel ORA_DISK_1: validation complete RMAN> validate backupset 5. using channel ORA_DISK_1 channel ORA_DISK_1: starting validation of datafile backupset channel ORA_DISK_1: restored backup piece 1 piece handle=/u01/oracle/archive/controlf_ORA920_04gah12n_4 tag=TAG20050118T1433 59 params=NULL channel ORA_DISK_1: validation complete Clause not backed up since time There are cases when backups faile and the stand becomes unclear. already backed up on datafile 5.

Sign up to vote on this title
UsefulNot useful