Copying files from ASM to File System

Working with Oracle technology is common to have two ways to do something, in this case move files from ASM storage to file system storage. We can do this job with rman or inside asmcmd.

1) Using ASMCMD Utility

lets use ASMCMD utility for copy files from ASM to OS as wel as from OS to ASM disk groups:

ASMCMD> cp EXAMPLE.265.697907183 /tmp/example01.bak
ASMCMD> cp /tmp/example01.bak +DATA/TESTDB/DATAFILE/example01.bak

we need to do with multiple files, this is a example for move a day archives out of asm storage

for i in $(asmcmd ls +FRA/PPOE/ARCHIVELOG/2016_03_31); do asmcmd cp +FRA/PPOE/ARCHIVELOG/2016_03_31/$i /mnt/backup/archives/; done

[oracle@dhcppc1 datafiles]$ ls -lrt
total 525208
-rw-r—– 1 oracle oinstall 314580992 Dec 31 13:17 ts2.dbf
[oracle@dhcppc1 datafiles]$

2) Using RMAN

[oracle@dhcppc1 datafiles]$ pwd
[oracle@dhcppc1 datafiles]$ ls
[oracle@dhcppc1 datafiles]$
SQL> create tablespace ts1 datafile ‘+DG1’ size 20m;

Tablespace created.

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name=’TS1′;

————— ———

SQL> select file_name,status from dba_data_files where file_id=8;

————————————————– ———
+DG1/testdb/datafile/ts1.256.739204397 AVAILABLE

[oracle@dhcppc1 datafiles]$ rman target / nocatalog

Recovery Manager: Release – Production on Fri Dec 31 14:34:15 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: TESTDB (DBID=2521935115)
using target database control file instead of recovery catalog

RMAN> copy datafile 8 to ‘/u01/datafiles/ts1.dbf’;

Starting backup at 31-DEC-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=31 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=+DG1/testdb/datafile/ts1.256.739204397
output file name=/u01/datafiles/ts1.dbf tag=TAG20101231T143435 RECID=7 STAMP=739204478
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 31-DEC-10


[oracle@dhcppc1 datafiles]$ ls -lrt
total 525208
-rw-r—– 1 oracle dba 314580992 Dec 31 14:40 ts1.dbf
[oracle@dhcppc1 datafiles]$
— Some usefull commands examples for manage asmcmd:

— Lists information about current Oracle ASM clients from the V$ASM_CLIENT view
ASMCMD> lsct
DB_Name Status Software_Version Compatible_version Instance_Name Disk_Group
testdb CONNECTED testdb DATA

— Can use the wildcard or can specify a particular file type by using the ‘–type’ clause

ASMCMD> find +DATA example*

— List the contents of an ASM Disk Group directory as well as attributes of files located in the directory
ASMCMD> ls -s
Block_Size Blocks Bytes Space Name
8192 12801 104865792 106954752 EXAMPLE.265.697907183
8192 89601 734011392 736100352 SYSAUX.257.697907095
8192 89601 734011392 736100352 SYSTEM.256.697907095
8192 7681 62922752 65011712 UNDOTBS1.258.697907095
8192 641 5251072 6291456 USERS.259.697907095
example01.bak => +DATA/ASM/DATAFILE/example01.bak.267.698929915

ASMCMD> ls -l
Type Redund Striped Time Sys Name
DATAFILE UNPROT COARSE SEP 30 11:00:00 Y EXAMPLE.265.697907183
DATAFILE UNPROT COARSE SEP 28 23:00:00 Y SYSAUX.257.697907095
DATAFILE UNPROT COARSE SEP 29 22:00:00 Y SYSTEM.256.697907095
DATAFILE UNPROT COARSE SEP 18 22:00:00 Y UNDOTBS1.258.697907095
DATAFILE UNPROT COARSE SEP 18 22:00:00 Y USERS.259.697907095
N example01.bak => +DATA/ASM/DATAFILE/example01.bak.267.698929915

— list information about a particular disk group
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Name
MOUNTED EXTERN N 512 4096 1048576 51200 49375 0 49375 DATA/

ASMCMD> lsdsk -t -G DATA
Create_Date Mount_Date Repair_Timer Path
18-SEP-09 18-SEP-09 0 /dev/raw/raw1



Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s