RMAN
Backup a database with RMAN as a copy and recover backup image
User Rating: / 0
- Details
-
Parent Category: Articles
-
Created on Thursday, 18 March 2010 21:17
-
Last Updated on Monday, 12 March 2012 13:54
-
Published on Thursday, 18 March 2010 21:17
-
Hits: 9710
Backup a database as a copy and recover backup image with incremental backups
This is a 10G feature and really cool
You take a backup as an image copy incremental level 0 ( in the below example a cold backup )
You take then backups as an image copy incremental level 1
You then recover the backup, so you recover your backup while it is offline, while your prod database keeps on running all the time.
You can use the RMAN command "switch database to copy" to switch to your / activate your backup ... in seconds.
You can use the RMAN command "switch tablespace tablespace_name to copy" to switch to your backed up tablespace
yes RMAN can
RMAN> run {
2> allocate channel ch1 device type DISK;
3> allocate channel ch2 device type DISK;
4> backup incremental level 0 as copy database;
5> }
released channel: ORA_DISK_1
allocated channel: ch1
channel ch1: SID=125 device type=DISK
allocated channel: ch2
channel ch2: SID=10 device type=DISK
Starting backup at 11-FEB-10
ignoring encryption for proxy or image copies
channel ch1: starting datafile copy
input datafile file number=00003 name=/opt/oradata/PLATINUM/undotbs01.dbf
channel ch2: starting datafile copy
input datafile file number=00005 name=/opt/oradata/PLATINUM/pm01.dbf
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_undotbs1_5q83rk1h_.dbf tag=TAG20100211T150712 RECID=40 STAMP=710694557
channel ch1: datafile copy complete, elapsed time: 00:02:06
channel ch1: starting datafile copy
input datafile file number=00002 name=/opt/oradata/PLATINUM/sysaux01.dbf
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm_5q83rl2z_.dbf tag=TAG20100211T150712 RECID=41 STAMP=710694557
channel ch2: datafile copy complete, elapsed time: 00:02:05
channel ch2: starting datafile copy
input datafile file number=00001 name=/opt/oradata/PLATINUM/system01.dbf
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_sysaux_5q83wgs8_.dbf tag=TAG20100211T150712 RECID=43 STAMP=710694671
channel ch1: datafile copy complete, elapsed time: 00:01:58
channel ch1: starting datafile copy
input datafile file number=00004 name=/opt/oradata/PLATINUM/users01.dbf
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_system_5q83wjy2_.dbf tag=TAG20100211T150712 RECID=42 STAMP=710694669
channel ch2: datafile copy complete, elapsed time: 00:01:56
channel ch2: starting datafile copy
input datafile file number=00006 name=/opt/oradata/PLATINUM/pm101.dbf
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm1_5q84063q_.dbf tag=TAG20100211T150712 RECID=44 STAMP=710694691
channel ch2: datafile copy complete, elapsed time: 00:00:15
channel ch2: starting datafile copy
input datafile file number=00007 name=/opt/oradata/PLATINUM/pm201.dbf
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm2_5q840oxf_.dbf tag=TAG20100211T150712 RECID=45 STAMP=710694706
channel ch2: datafile copy complete, elapsed time: 00:00:16
channel ch2: starting datafile copy
input datafile file number=00008 name=/opt/oradata/PLATINUM/pm301.dbf
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm3_5q8415sw_.dbf tag=TAG20100211T150712 RECID=46 STAMP=710694722
channel ch2: datafile copy complete, elapsed time: 00:00:15
channel ch2: starting datafile copy
input datafile file number=00009 name=/opt/oradata/PLATINUM/USERS_ARCHIVE_01.dbf
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_users_ar_5q841ol8_.dbf tag=TAG20100211T150712 RECID=47 STAMP=710694739
channel ch2: datafile copy complete, elapsed time: 00:00:15
channel ch2: starting datafile copy
input datafile file number=00010 name=/opt/oradata/PLATINUM/USERS_ARCHIVE_02.dbf
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_users_5q8404f1_.dbf tag=TAG20100211T150712 RECID=48 STAMP=710694744
channel ch1: datafile copy complete, elapsed time: 00:01:13
channel ch1: starting datafile copy
input datafile file number=00011 name=/opt/oradata/PLATINUM/TS_APEX_01.dbf
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_users_ar_5q84262d_.dbf tag=TAG20100211T150712 RECID=49 STAMP=710694749
channel ch2: datafile copy complete, elapsed time: 00:00:09
channel ch2: starting datafile copy
copying current control file
output file name=/opt/flash_recovery_area/PLATINUM/controlfile/o1_mf_TAG20100211T150712_5q842hbz_.ctl tag=TAG20100211T150712 RECID=50 STAMP=710694753
channel ch2: datafile copy complete, elapsed time: 00:00:03
channel ch2: starting incremental level 0 datafile backup set
channel ch2: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ch2: starting piece 1 at 11-FEB-10
channel ch2: finished piece 1 at 11-FEB-10
piece handle=/opt/flash_recovery_area/PLATINUM/backupset/2010_02_11/o1_mf_nnsn0_TAG20100211T150712_5q842lz6_.bkp tag=TAG20100211T150712 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:02
output file name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_ts_apex_5q842fml_.dbf tag=TAG20100211T150712 RECID=51 STAMP=710694757
channel ch1: datafile copy complete, elapsed time: 00:00:09
Finished backup at 11-FEB-10
released channel: ch1
released channel: ch2
oracle@pcguy PLATINUM$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Thu Feb 11 15:30:25 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PLATINUM (DBID=2439336951, not open)
RMAN> run {
2> backup incremental level 1 for recover of copy database;
3> recover copy of database;
4> }
Starting backup at 11-FEB-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/opt/oradata/PLATINUM/undotbs01.dbf
input datafile file number=00005 name=/opt/oradata/PLATINUM/pm01.dbf
input datafile file number=00002 name=/opt/oradata/PLATINUM/sysaux01.dbf
input datafile file number=00001 name=/opt/oradata/PLATINUM/system01.dbf
input datafile file number=00006 name=/opt/oradata/PLATINUM/pm101.dbf
input datafile file number=00007 name=/opt/oradata/PLATINUM/pm201.dbf
input datafile file number=00008 name=/opt/oradata/PLATINUM/pm301.dbf
input datafile file number=00009 name=/opt/oradata/PLATINUM/USERS_ARCHIVE_01.dbf
input datafile file number=00010 name=/opt/oradata/PLATINUM/USERS_ARCHIVE_02.dbf
input datafile file number=00011 name=/opt/oradata/PLATINUM/TS_APEX_01.dbf
channel ORA_DISK_1: starting piece 1 at 11-FEB-10
channel ORA_DISK_1: finished piece 1 at 11-FEB-10
piece handle=/opt/flash_recovery_area/PLATINUM/backupset/2010_02_11/o1_mf_nnnd1_TAG20100211T153102_5q85572s_.bkp tag=TAG20100211T153102 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:05
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/opt/oradata/PLATINUM/users01.dbf
channel ORA_DISK_1: starting piece 1 at 11-FEB-10
channel ORA_DISK_1: finished piece 1 at 11-FEB-10
piece handle=/opt/flash_recovery_area/PLATINUM/backupset/2010_02_11/o1_mf_nnnd1_TAG20100211T153102_5q85949o_.bkp tag=TAG20100211T153102 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 11-FEB-10
channel ORA_DISK_1: finished piece 1 at 11-FEB-10
piece handle=/opt/flash_recovery_area/PLATINUM/backupset/2010_02_11/o1_mf_ncsn1_TAG20100211T153102_5q859pl6_.bkp tag=TAG20100211T153102 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-FEB-10
Starting recover at 11-FEB-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00001 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_system_5q83wjy2_.dbf
recovering datafile copy file number=00002 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_sysaux_5q83wgs8_.dbf
recovering datafile copy file number=00003 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_undotbs1_5q83rk1h_.dbf
recovering datafile copy file number=00005 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm_5q83rl2z_.dbf
recovering datafile copy file number=00006 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm1_5q84063q_.dbf
recovering datafile copy file number=00007 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm2_5q840oxf_.dbf
recovering datafile copy file number=00008 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm3_5q8415sw_.dbf
recovering datafile copy file number=00009 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_users_ar_5q841ol8_.dbf
recovering datafile copy file number=00010 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_users_ar_5q84262d_.dbf
recovering datafile copy file number=00011 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_ts_apex_5q842fml_.dbf
channel ORA_DISK_1: reading from backup piece /opt/flash_recovery_area/PLATINUM/backupset/2010_02_11/o1_mf_nnnd1_TAG20100211T153102_5q85572s_.bkp
channel ORA_DISK_1: piece handle=/opt/flash_recovery_area/PLATINUM/backupset/2010_02_11/o1_mf_nnnd1_TAG20100211T153102_5q85572s_.bkp tag=TAG20100211T153102
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00004 name=/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_users_5q8404f1_.dbf
channel ORA_DISK_1: reading from backup piece /opt/flash_recovery_area/PLATINUM/backupset/2010_02_11/o1_mf_nnnd1_TAG20100211T153102_5q85949o_.bkp
channel ORA_DISK_1: piece handle=/opt/flash_recovery_area/PLATINUM/backupset/2010_02_11/o1_mf_nnnd1_TAG20100211T153102_5q85949o_.bkp tag=TAG20100211T153102
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 11-FEB-10
RMAN> list backup summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
22 B 0 A DISK 11-FEB-10 1 1 NO TAG20100211T150712
23 B 1 A DISK 11-FEB-10 1 1 NO TAG20100211T151826
24 B 1 A DISK 11-FEB-10 1 1 NO TAG20100211T153102
25 B 1 A DISK 11-FEB-10 1 1 NO TAG20100211T153102
26 B 1 A DISK 11-FEB-10 1 1 NO TAG20100211T153102
RMAN>
list copy of database;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
58 1 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_system_5q83wjy2_.dbf
Tag: TAG20100211T150712
59 2 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_sysaux_5q83wgs8_.dbf
Tag: TAG20100211T150712
60 3 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_undotbs1_5q83rk1h_.dbf
Tag: TAG20100211T150712
62 4 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_users_5q8404f1_.dbf
Tag: TAG20100211T150712
61 5 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm_5q83rl2z_.dbf
Tag: TAG20100211T150712
52 6 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm1_5q84063q_.dbf
Tag: TAG20100211T150712
53 7 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm2_5q840oxf_.dbf
Tag: TAG20100211T150712
54 8 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_pm3_5q8415sw_.dbf
Tag: TAG20100211T150712
55 9 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_users_ar_5q841ol8_.dbf
Tag: TAG20100211T150712
56 10 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_users_ar_5q84262d_.dbf
Tag: TAG20100211T150712
57 11 A 11-FEB-10 4607459 11-FEB-10
Name: /opt/flash_recovery_area/PLATINUM/datafile/o1_mf_ts_apex_5q842fml_.dbf
Tag: TAG20100211T150712
It is the right place and moment to highlight the RMAN commands "switch database to copy" and "switch tablespace tablespace_name to copy"
RMAN > switch database to copy
RMAN>
switch tablespace users to copy;
datafile 4 switched to datafile copy "/opt/flash_recovery_area/PLATINUM/datafile/o1_mf_users_5q8404f1_.dbf"
RMAN>
sql "alter database open";
sql statement: alter database open