Multiple copies (cp) with Oracle ASM asmcmd tool

oracle

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.

Best Answer

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.