当前位置: 首页 > BACKUP & RESTORE > 正文

backup as copy保留文件名不变化,只更改路径名

         有些时候可能会用到backup as copy的方式来将数据库从一个目录迁移到另一个目录,如更改存储时,怎么保存文件名不变,只更改路径名,如果在ASM环境很简单,直接使用backup as copy format ‘+DGNAME’的方式就可以实现了,因为磁盘组中的文件名是ORACLE自动管理的,但是如果是文件系统就不能通过FORMAT的方式来实现了。实现方式见下面步骤

欢迎大家加入ORACLE超级群:17115662 免费解决各种ORACLE问题,以后BLOG将迁移到http://www.htz.pw

1,数据库版本

swww.htz.pw > elect * from v$version;

 

BANNER

——————————————————————————–

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production

PL/SQL Release 11.2.0.4.0 – Production

CORE    11.2.0.4.0      Production

TNS for Linux: Version 11.2.0.4.0 – Production

NLSRTL Version 11.2.0.4.0 – Production

2rman备份数据库

run {

allocate channel D1 type disk;

BACKUP AS COPY  DB_FILE_NAME_CONVERT=(‘/oracle/app/oracle/oradata/orcl1124′,’/soft/rman’) FORMAT=’/soft/rman/spfile_and_control_%U’ database;

}

如果这里有多个路径,我们可以在db_file_name_convert增加上多个目录,但是需要注意的是必须成对出现,如果没有成对出现的,将会备份到format指定的目录中。这里增加format的作用是将controlfilespfile备份到指定的路径下

RMAN> run {

2> allocate channel D1 type disk;

3> BACKUP AS COPY  DB_FILE_NAME_CONVERT=(‘/oracle/app/oracle/oradata/orcl1124′,’/soft/rman’) FORMAT=’/soft/rman/spfile_and_control_%U’ database;

4> }

 

released channel: ORA_DISK_1

allocated channel: D1

channel D1: SID=50 device type=DISK

 

Starting backup at 03-JUN-14

channel D1: starting datafile copy

input datafile file number=00001 name=/oracle/app/oracle/oradata/orcl1124/system01.dbf

output file name=/soft/rman/system01.dbf tag=TAG20140603T222947 RECID=16 STAMP=849306632

channel D1: datafile copy complete, elapsed time: 00:00:55

channel D1: starting datafile copy

input datafile file number=00002 name=/oracle/app/oracle/oradata/orcl1124/sysaux01.dbf

output file name=/soft/rman/sysaux01.dbf tag=TAG20140603T222947 RECID=17 STAMP=849306679

channel D1: datafile copy complete, elapsed time: 00:00:46

channel D1: starting datafile copy

input datafile file number=00005 name=/oracle/app/oracle/oradata/orcl1124/htz01.dbf

output file name=/soft/rman/htz01.dbf tag=TAG20140603T222947 RECID=18 STAMP=849306695

channel D1: datafile copy complete, elapsed time: 00:00:15

channel D1: starting datafile copy

input datafile file number=00003 name=/oracle/app/oracle/oradata/orcl1124/undotbs01.dbf

output file name=/soft/rman/undotbs01.dbf tag=TAG20140603T222947 RECID=19 STAMP=849306709

channel D1: datafile copy complete, elapsed time: 00:00:15

channel D1: starting datafile copy

input datafile file number=00006 name=/oracle/app/oracle/oradata/orcl1124/undotbs02.dbf

output file name=/soft/rman/undotbs02.dbf tag=TAG20140603T222947 RECID=20 STAMP=849306719

channel D1: datafile copy complete, elapsed time: 00:00:03

channel D1: starting datafile copy

copying current control file

output file name=/soft/rman/spfile_and_control_cf_D-ORCL1124_id-3333857950_1ip9up31 tag=TAG20140603T222947 RECID=21 STAMP=849306722

channel D1: datafile copy complete, elapsed time: 00:00:01

channel D1: starting datafile copy

input datafile file number=00004 name=/oracle/app/oracle/oradata/orcl1124/users01.dbf

output file name=/soft/rman/users01.dbf tag=TAG20140603T222947 RECID=22 STAMP=849306723

channel D1: datafile copy complete, elapsed time: 00:00:01

channel D1: starting full datafile backup set

channel D1: specifying datafile(s) in backup set

including current SPFILE in backup set

channel D1: starting piece 1 at 03-JUN-14

channel D1: finished piece 1 at 03-JUN-14

piece handle=/soft/rman/spfile_and_control_1kp9up34_1_1 tag=TAG20140603T222947 comment=NONE

channel D1: backup set complete, elapsed time: 00:00:01

Finished backup at 03-JUN-14

released channel: D1

3,生成的文件名

查看生成的文件名,这里发现文件名没有发生变化

[oracle@www.htz.pw rman]$ls -lrt

total 1602304

-rwxrwSrwt  1 oracle oinstall 786440192 Jun  3 22:30 system01.dbf

-rwxrwSrwt  1 oracle oinstall 639639552 Jun  3 22:31 sysaux01.dbf

-rwxrwSrwt  1 oracle oinstall 104865792 Jun  3 22:31 htz01.dbf

-rwxrwSrwt  1 oracle oinstall  83894272 Jun  3 22:31 undotbs01.dbf

-rwxrwSrwt  1 oracle oinstall  10493952 Jun  3 22:31 undotbs02.dbf

-rwxrwSrwt  1 oracle oinstall  10076160 Jun  3 22:31 spfile_and_control_cf_D-ORCL1124_id-3333857950_1ip9up31

-rwxrwSrwt  1 oracle oinstall   5251072 Jun  3 22:31 users01.dbf

-rwxrwSrwt  1 oracle oinstall     98304 Jun  3 22:31 spfile_and_control_1kp9up34_1_1

本文固定链接: http://www.htz.pw/2014/06/03/backup-as-copy%e4%bf%9d%e7%95%99%e6%96%87%e4%bb%b6%e5%90%8d%e4%b8%8d%e5%8f%98%e5%8c%96%ef%bc%8c%e5%8f%aa%e6%9b%b4%e6%94%b9%e8%b7%af%e5%be%84%e5%90%8d.html | 认真就输

该日志由 huangtingzhong 于2014年06月03日发表在 BACKUP & RESTORE 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: backup as copy保留文件名不变化,只更改路径名 | 认真就输
关键字:
  1. How To Generate Same Name For RMAN Datafile Copies (文档 ID 562548.1)修改时间:2008-4-10类型:HOWTOIn this Document  Goal  SolutionThis document is being delivered to you via Oracle Support’s Rapid Visibility (RaV) process, and therefore has not been subject to an independent technical review.APPLIES TO:Oracle Server – Enterprise Edition – Version: 10.1.0.0 to 11.1Information in this document applies to any platform.GOALWanted to generate same name for the datafile copies with RMAN “Backup as Copy Database” CommandSOLUTIONWhen creating image copies, you can also name the output copies with the DB_FILE_NAME_CONVERT option of the BACKUP command. This parameter works identically to the initialization parameter DB_FILE_NAME_CONVERT. Pairs of filename prefixes are provided to change the names of the output files. If a file is not converted by any of the pairs, then RMAN uses the FORMAT specification; if no FORMAT is specified, then RMAN uses the default format %U. For example, you can run the following command to copy the datafiles whose filename is prefixed with /maindisk/oradata so that they are prefixed with /backups/prod : RMAN> BACKUP AS COPY DEVICE TYPE DISK DB_FILE_NAME_CONVERT=(‘/maindisk/oradata’,’/backups/prod’) database;The names of the datafile copies will be same as the actual datafile names.