cp

Purpose

Enables you to copy files between Oracle ASM disk groups and between a disk group and the operating system.

Syntax and Description

cp src_file [--service service_name] [--port port_num] [connect_str:]tgt_file

Table 10-32 lists the syntax options for the cp command.


Table 10-32 Options for the cp command

Option Description

--service service_name

Specifies the Oracle ASM instance name if not the default +ASM.

--port port_num

Specifies the listener port number. The default is 1521.

connect_str

Specifies the connection string for a remote instance.

src_file

Name of the source file to copy.

tgt_file

A user alias for the created target file name or an alias directory name.


cp cannot copy files between two remote instances. The local Oracle ASM instance must be either the source or the target of the operation.

You can use the cp command to:

  • Copy files from a disk group to the operating system

  • Copy files from a disk group to a disk group

  • Copy files from the operating system to a disk group

Some file types cannot be the source or destination of the cp command. These file types include OCR and OCR backup file types. To back up, copy, or move an Oracle ASM SPFILE, use the spbackup, spcopy, or spmove commands.

The format of copied files is portable between Little-Endian and Big-Endian systems if the files exist in an Oracle ASM disk group. Oracle ASM automatically converts the format when the files are written. For copying a non-Oracle ASM file from or to an Oracle ASM disk group, you can copy the file to a different endian platform and then use one of the commonly used utilities to convert the file.

connect_str is not required for a local instance copy, which is the default case. For a remote instance copy, you must specify the connect string and Oracle ASM prompts for a password in a non-echoing prompt. The connect_str is in the form:

user@host.SID

user, host, and SID are required in the connect_str parameter. The default port number is 1521 and can be changed with the --port option.

The connection privilege (SYSASM or SYSDBA) is determined by the use of the --privilege option when starting ASMCMD. For more information, refer to "Specifying the Type of Connection".

See Also:

Oracle Database Net Services Administrator's Guide for more information about connection strings

src_file must be either a fully qualified file name or an Oracle ASM alias.

During an ASMCMD copy process, the Oracle ASM server creates an Oracle Managed File (OMF) file in the following format:

diskgroup/db_unique_name/file_type/file_name.#.#

where db_uniq_name is set to ASM and # is a string of digits. In the copy process, ASMCMD cp creates the directory structure for the destination and creates a user alias from that location to the actual OMF file that is created.

Examples

The following are examples of the cp command. The first example shows a copy of a file in the data disk group to a file on the operating system. The second example shows a copy of a file on the operating system to the data disk group. The third example shows how to copy a file in the data disk group to a remote server. You are prompted to enter a password.

Example 10-41 Using the ASMCMD cp command

ASMCMD [+] > cp +data/orcl/datafile/EXAMPLE.265.691577295 /mybackups/example.bak
copying +data/orcl/datafile/EXAMPLE.265.691577295 -> /mybackups/example.bak

ASMCMD [+] >  cp /mybackups/examples.bak  +data/orcl/datafile/myexamples.bak
copying /mybackups/examples.bak -> +data/orcl/datafile/myexamples.bak

ASMCMD [+] > cp +data/orcl/datafile/EXAMPLE.265.691577295 sys@myserver.+ASM:/scratch/backup/myexamples.bak
Enter Password: