RMAN provides a convenient way to name Image Copies (backups) of datafiles to retain the same file name without the path. This is possible with the "%b" FORMAT modifier.
Here's a demo :
However, this fails with OMF files and controlfile auto backups.
Also, you have to be careful to check that you do not have two datafiles with the same name in two different folders. RMAN recognises the presence of the first datafile copied and raises an error on the second datafile
For example :
The %b format for datafiles is also supposed to be usable with the SET NEWNAME clause in a RESTORE run.
.
.
.
Here's a demo :
[oracle@localhost ~]$ cd /IMA*/ORCL* [oracle@localhost ORCL_DB]$ pwd /IMAGE_BACKUP/ORCL_DB [oracle@localhost ORCL_DB]$ rman target / Recovery Manager: Release 11.2.0.2.0 - Production on Sun Feb 23 23:24:55 2014 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (DBID=1229390655) RMAN> backup as copy database format '/IMAGE_BACKUP/ORCL_DB/%b'; Starting backup at 23-FEB-14 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=37 device type=DISK channel ORA_DISK_1: starting datafile copy input datafile file number=00002 name=/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf output file name=/IMAGE_BACKUP/ORCL_DB/sysaux01.dbf tag=TAG20140223T232527 RECID=3 STAMP=840324368 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45 channel ORA_DISK_1: starting datafile copy input datafile file number=00001 name=/home/oracle/app/oracle/oradata/orcl/system01.dbf output file name=/IMAGE_BACKUP/ORCL_DB/system01.dbf tag=TAG20140223T232527 RECID=4 STAMP=840324400 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=/home/oracle/app/oracle/oradata/orcl/users01.dbf output file name=/IMAGE_BACKUP/ORCL_DB/users01.dbf tag=TAG20140223T232527 RECID=5 STAMP=840324414 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile copy input datafile file number=00011 name=/home/oracle/app/oracle/oradata/orcl/ORCL/datafile/o1_mf_hemant_8pnowslc_.dbf RMAN-03009: failure of backup command on ORA_DISK_1 channel at 02/23/2014 23:26:55 ORA-01276: Cannot add file /IMAGE_BACKUP/ORCL_DB/o1_mf_hemant_8pnowslc_.dbf. File has an Oracle Managed Files file name. continuing other job steps, job failed will not be re-run channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf output file name=/IMAGE_BACKUP/ORCL_DB/undotbs01.dbf tag=TAG20140223T232527 RECID=6 STAMP=840324420 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile copy input datafile file number=00005 name=/home/oracle/app/oracle/oradata/orcl/example01.dbf output file name=/IMAGE_BACKUP/ORCL_DB/example01.dbf tag=TAG20140223T232527 RECID=7 STAMP=840324428 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile copy copying current control file RMAN-03009: failure of backup command on ORA_DISK_1 channel at 02/23/2014 23:27:12 ORA-19715: invalid format b for generated name ORA-27302: failure occurred at: slgpn continuing other job steps, job failed will not be re-run channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 23-FEB-14 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03009: failure of backup command on ORA_DISK_1 channel at 02/23/2014 23:27:12 ORA-19715: invalid format b for generated name ORA-27302: failure occurred at: slgpn RMAN> RMAN> quit Recovery Manager complete. [oracle@localhost ORCL_DB]$ pwd /IMAGE_BACKUP/ORCL_DB [oracle@localhost ORCL_DB]$ pwd /IMAGE_BACKUP/ORCL_DB [oracle@localhost ORCL_DB]$ ls -l total 2641496 -rw-rw---- 1 oracle oracle 85991424 Feb 23 23:27 example01.dbf -rw-rw---- 1 oracle oracle 1320165376 Feb 23 23:26 sysaux01.dbf -rw-rw---- 1 oracle oracle 881860608 Feb 23 23:26 system01.dbf -rw-rw---- 1 oracle oracle 178266112 Feb 23 23:27 undotbs01.dbf -rw-rw---- 1 oracle oracle 235937792 Feb 23 23:26 users01.dbf [oracle@localhost ORCL_DB]$
However, this fails with OMF files and controlfile auto backups.
Also, you have to be careful to check that you do not have two datafiles with the same name in two different folders. RMAN recognises the presence of the first datafile copied and raises an error on the second datafile
For example :
SQL> create tablespace test_tbs datafile '/home/oracle/app/oracle/oradata/orcl/test_tbs_01.dbf' size 100M; Tablespace created. SQL> alter tablespace test_tbs add datafile '/tmp/test_tbs_01.dbf' size 50M; Tablespace altered. SQL> SQL> !ls -l /home/oracle/app/oracle/oradata/orcl/test_tbs_01.dbf -rw-rw---- 1 oracle oracle 104865792 Feb 23 23:34 /home/oracle/app/oracle/oradata/orcl/test_tbs_01.dbf SQL> !ls -l /tmp/test_tbs_01.dbf -rw-rw---- 1 oracle oracle 52436992 Feb 23 23:34 /tmp/test_tbs_01.dbf SQL> exit RMAN> backup as copy tablespace test_tbs format '/IMAGE_BACKUP/ORCL_DB/%b'; Starting backup at 23-FEB-14 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=47 device type=DISK channel ORA_DISK_1: starting datafile copy input datafile file number=00006 name=/home/oracle/app/oracle/oradata/orcl/test_tbs_01.dbf output file name=/IMAGE_BACKUP/ORCL_DB/test_tbs_01.dbf tag=TAG20140223T233608 RECID=8 STAMP=840324970 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile copy input datafile file number=00007 name=/tmp/test_tbs_01.dbf RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03009: failure of backup command on ORA_DISK_1 channel at 02/23/2014 23:36:13 ORA-19504: failed to create file "/IMAGE_BACKUP/ORCL_DB/test_tbs_01.dbf" ORA-27038: created file already exists Additional information: 1 RMAN>
The %b format for datafiles is also supposed to be usable with the SET NEWNAME clause in a RESTORE run.
.
.
.
No comments:
Post a Comment