Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

In order to import a transportable tablespace into an Oracle 11 database with ASM, we use the cp command of the asmcmd tool.

How can we copy more than one file at a time?

Wildcards are not supported, copying directories either, and I can't find any hint if asmcmd has a scripting mechanism.

share|improve this question
add comment

migrated from stackoverflow.com Jun 28 '11 at 14:01

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 6 down vote accepted
+50

Since no platform or version is mentioned, I assume Unix/Linux and 11gR2.

First of all, check Running ASMCMD in Noninteractive Mode. This explains that we can use ASMCMD in a script so whatever we can dream of, we can script. In this case in order to copy files we can use

asmcmd command options

A simple example is shown here Running ASMCMD commands in a script Change this example slightly to get it to copy all files in a local directory, also using this Using the ASMCMD cp command as input:

ls | while read FILE
do
   asmcmd cp $FILE +data/orcl/datafile/$FILE
done

I am not sure how smart it is to run multiple copies in parallel. It all depends on what your hardware can handle. If you want to run in parallel, run the copies in the background but be a little careful, when running too much in parallel, it will definately cause a slower throughput than running in a sequential way.

For windows it will be slightly different, the loop construct will be different.

I hope this helps.

share|improve this answer
    
Might you need to use asmcmd ls? –  Jack Douglas Jul 1 '11 at 11:37
    
not if you copy from fs to ASM, but the other way around: yes. –  ik_zelf Jul 1 '11 at 11:43
add comment

For example, on Linux (or other Unix-type systems):

for i in $(asmcmd ls +DG_AL/EMREP/ARCHIVELOG/2012_12_04); do
  asmcmd cp +DG_AL/EMREP/ARCHIVELOG/2012_12_04/$i /u01
done

This technique would be useful if you were copying from the ASM to the filesystem locally.

Just as a refresher, the way this script works is:

  • asmcmd ls +DG_AL/EMREP/ARCHIVELOG/2012_12_04: list files inside that ASM directory. The list contains filenames only, not the paths.
  • for i in $(command) ; do ... ; done: iterate over the output of command, using $i as the loop variable. $i will contain the name of one file (without path) inside the loop
  • asmcmd cp [asm_path]/$i [external_path]: copies one file from ASM to an external path.

You could do external to ASM the same way (do an ordinary ls or find for the loop command, and exchange the paths in the copy), or even ASM to ASM (both paths can be ASM paths for asmcmd cp).

share|improve this answer
    
A valiant effort, and this is exactly how we like people to contribute and keep question/answer sets as canonical resources for those looking to understand later, but first: blog-credits, taglines, signatures - we ask that you not use taglines (see the faq) for your own property, but if you refer to a very specific post on your blog, and the answer here is sufficient to answer the question, then we welcome a link to a much more indepth explanation; and as for this answer, maybe you noticed the other comments that mention this is if you copy INTO the ASM? Can you elaborate? –  jcolebrand Dec 11 '12 at 15:18
1  
I gave something of a trivial explanation, so that those who are not familiar with the problem can understand the breakdown, and I applied code formatting (there is a very lovely toolbar above the editor textbox or you can just indent four spaces at the start of a line, or paste in with a tab at the leading edge) but you may want to rewrite this to be better explained. Don't forget the folks reading this could be veterans, or absolute noobs. –  jcolebrand Dec 11 '12 at 15:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.