Hello,
In this post, we will look different ways of copying Files between OS and ASM.
Before to that we see what are the tools available for the same.
- XML DB - enables file transfer since Oracle 10gR1
XML DB creates a virtual folder /sys/asm and makes it accessible via ftp or http. You will see how to use XML DB features for transferring files between file system and ASM using the virtual /sys/asm folder. In order to use this feature for file transfer XML DB needs to be installed and configured
Full details available here: http://docs.oracle.com/cd/B28359_01/server.111/b31107/asmfiles.htm#BABJCCEI
- ASMCMD cp command since Oracle 11g
Starting with 11G asmcmd is further enhanced and one of the benefits is cp. ASMCMD cp command can be used to copy both locally and remotely in the following directions:
- ASM->FS
- FS->ASM
- ASM-ASM
ASMCMD [+] > cp +data/orcl/datafile/TEST.267.78569634 /mybackups/example.bak
copying +data/orcl/datafile/TEST.267.78569634 -> /mybackups/example.bak
ASMCMD [+] > cp /mybackups/test.txt +data/orcl/datafile/test.txt
copying /mybackups/examples.bak -> +data/orcl/datafile/myexamples.bak
ASMCMD [+] > cp +data/orcl/datafile/TEST.267.78569634 sys@server.asminstance:/home/oracle
ASMCMD [+] > cp +data/orcl/datafile/TEST.267.78569634 sys/passwd@server.asminstance:/home/oracle
ASMCMD [+] > cp sys@server.asminstance:/home/oracle +data/orcl/datafile/file
- DBMS_FILE_TRANSFER package - allowed transfer between ASM/FS since 10gR2
DBMS_FILE_TRANSFER package is available since Oracle 10gR1 and since 10gR2 supports transferring files as follows:
- ASM->ASM
- FS->ASM
- FS->FS
- FS->ASM
Let's create a directory pointing to a file system
CREATE OR REPLACE DIRECTORY fs_dir AS '/home/oracle/stage_file';
Let's create a directory pointing to ASM
CREATE OR REPLACE DIRECTORY ASM_dir AS '+DATA/tst';
to copy example.txt file from ASM to a /home/oracle/stage_file directory.
SQL> exec dbms_file_transfer.COPY_FILE('asm_dir','example.txt','fs_dir','example.txt');
PL/SQL procedure successfully completed.
-Thanks
Geek DBA
Very Very useful post
Hello Siva,
Thanks visiting and nice comments here.
-Regards
Geek DBA