To copy a file from a source (such as a network server) to a destination (such as a flash disk), use the
copy command in EXEC or administration EXEC mode.
copy
source
{ location
node-id
destination
location
{ node-id | all } | running-config [atomic] }
Syntax Description
source |
Filename including the directory path or network location of the file. The possible sources are: directory-path —Directory path of the file from which the file is copied. access-list { ipv4 | ipv6 }—Copies an access list (EXEC mode only). bootflash: —Copies from the bootflash: file system. compactflash: —Copies from the compactflash: file system. compactflasha: —Copies from the compactflasha: file system partition. disk0: —Copies from disk0: file system. disk0a: —Copies from disk0a: file system partition. disk1: —Copies from disk1: file system. disk1a: —Copies from disk1a: file system partition. flash: —Copies from the flash: file system. The flash: keyword is an alias for bootflash:. ftp: —Copies from an FTP network server. The syntax is ftp:[[[//username [:password]@] location]/directory]/filename. harddisk: —Copies from the hard disk drive file system (if present). harddiska: —Copies from the hard disk partition a. harddiskb: —Copies from the hard disk partition b. nvram: —Copies from the NVRAM file system. prefix-list {ipv4 | ipv6}—Copies from a prefix list (EXEC mode only). rcp: —Copies from a remote copy protocol (rcp) network server. The syntax is rcp:[[[//username@]location]/directory]/filename. running-config —Copies from the current system configuration. tftp: —Copies from a TFTP network server. The syntax is tftp:[[//location]/directory]/filename xml-schema —Copies the XML schema files as a tar ball file (.tar.gz) [EXEC mode only]. |
destination |
Filename including the directory path or network location of the file. |
location node-id |
Specifies a node. The node-id argument is expressed in the rack/slot/module notation. |
location all |
Copies to all nodes. |
running-config |
Applies the source configuration file to the running configuration of the system. |
atomic |
(Optional) Applies the changes to the running configuration only if there are no errors |
Command Default
No default behavior or values
Command Modes
EXEC
Administration EXEC
Command History
Releases |
Modifications |
Release 3.2 |
This command was introduced. |
Release 3.3.0 |
No modification. |
Release 3.4.0 |
No modification. |
Release 3.5.0 |
Support was added to copy XML schema files. |
Release 3.6.0 |
The following file systems were added: disk0a: , disk1a: , and compactflasha: . |
Release 3.7.0 |
No modification. |
Release 3.8.0 |
No modification. |
Release 3.9.0 |
No modification. |
Usage Guidelines
To use this command, you must be in a user group associated with a task group that includes appropriate task IDs. If the user group assignment is preventing you from using a command, contact your AAA administrator for assistance.
Source and destination can each be a configuration file, a text file, or a file system. Enter source and destination URL information, usernames, and passwords and issue the copy command. The networking device prompts for any missing information.
The exact format of the source and destination arguments vary according to the file or directory location. Enter the device or network location for the file system type.
Filenames can include the following characters:
! # $ % & ' + 0 1 2 3 4 5 6 7 8 9 ; @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ ] ^ _ a b c d e f g h i j k l m n o p q r s t u v w x y z { } ~
The following characters can be used with the stated limitations:
-
` needs backslash before this character
-
– cannot be the first character
-
. cannot be the last character
-
= cannot be the filename without other characters
The following characters cannot be used in filenames:
" ( ) * , / : < > ? \ |
To copy a file from a source on the router to a destination on the router, specify a source location node-id and a destination location node-id . To copy the file to all nodes, use the location all keywords.
In the alias syntax for the ftp: , rcp: , and tftp: keywords, the location is either an IP address or a hostname. The filename is specified relative to the directory used for file transfers.
When no alias is specified, the networking device looks for a file in the current directory. To view the current directory, enter the pwd command.
Note |
During processing of the copy command, you might see the “C” character. For all files being copied, “C” indicates that the copy process is taking place. The entire copying process might take several minutes and differs from protocol to protocol and from network to network.
|
Table 1 describes the network protocols supported by Cisco IOS XR software.
Table 1 Network Protocols Supported by Cisco IOS XR Software
Prefix |
Name |
Description |
tftp: |
Trivial File Transfer Protocol |
TFTP is a simplified version of FTP that allows files to be transferred from one computer to another over a network, usually without the use of client authentication (for example, username and password). |
ftp: |
File Transfer Protocol |
FTP is an application protocol, part of the TCP/IP protocol stack, and is used for transferring files between network nodes. FTP requires a username and password. |
rcp: |
Remote Copy Protocol |
The rcp protocol allows users to copy files to and from a file system residing on a remote host or server on the network. The rcp protocol uses TCP to ensure the reliable delivery of data. The rcp protocol downloads require a username. |
Additional usage guidelines are in the following sections.
Invalid Combinations of Source and Destination
Some combinations of source and destination are invalid. Specifically, you cannot copy the following:
-
From a running configuration to a running configuration
-
From a network device to a network device (for example, copy ftp: rcp: )
Using TFTP
TFTP is a simplified version of FTP that allows files to be transferred from one computer to another over a network, usually without the use of client authentication (for example, username and password).
The syntax is as follows:
copy tftp://hostname /ipaddress/directory-path pie name target-device [location {node-id | all}]
Example:
RP/0/0/CPU0:router# copy tftp://1.1.1.1/images/software.pie disk1:
Note |
Some Cisco IOS XR images may be larger than 32 MB, and the TFTP services provided by some vendors may not support a file this large. If you do not have access to a TFTP server that supports files larger than 32 MB, download the software image using FTP or rcp as described in the following sections.
|
Using FTP
FTP servers require a username and password for each client request. Cisco IOS XR software sends the first valid username in the following list:
-
The username and password specified in the copy command, if a username is specified. The syntax is as follows: copy ftp:// username : password @ hostname or ipaddress/directory-path/pie-name target-device [location {node-id | all}]
Example:
RP/0/0/CPU0:router# copy ftp://john:secret@10.1.1.1/images/software.pie disk1:
-
An “anonymous” username and password. The anonymous password is “root@ip address,” where “ip address” is the IP address of the local networking device.
-
A password “username@iosname.domain” formed by the networking device. The variable “username” is the username associated with the current session, “iosname” is the configured hostname, and “domain” is the domain of the networking device.
The username and password must be associated with an account on the FTP server. If you are writing to the network server, the FTP server must be properly configured to accept the FTP write request from the user on the networking device.
If the network server has a directory structure, the configuration file or image is written to or copied from the directory associated with the username on the network server. For example, if the system image resides in the home directory of a user on the network server, specify the name of that user as the remote username.
Refer to the documentation for your FTP server for more details.
Using rcp
The rcp protocol requires a username upon each request. When you copy a configuration file or image between the networking device and an rcp server, the Cisco IOS XR software sends the first valid username in the following list:
-
The remote username specified in the copy command, if one is specified.
-
The username set by the rcp client username command, if the command is configured.
-
The networking device hostname.
For the rcp copy request to process successfully, an account must be defined on the network server for the remote username. If the network administrator of the destination server did not establish an account for the remote username, this command does not run successfully. If the network server has a directory structure, the configuration file or image is written to or copied from the directory associated with the remote username on the network server. For example, if the system image resides in the home directory of a user on the network server, specify the name of that user as the remote username.
If you are writing to the network server, the rcp server must be properly configured to accept the rcp write request from the user on the networking device. For UNIX systems, add an entry to the .rhosts file for the remote user on the rcp server. Suppose the networking device contains the following configuration lines:
hostname Rtr1
ip rcp remote-username User0
If the IP address of the networking device translates to company.com, then the .rhosts file for User0 on the rcp server should contain the following line:
company.com Rtr1
See the documentation for your rcp server for more details.
If you are using a personal computer as a file server, the computer must support remote shell (rsh) protocol.
Using xml-schema
Use the xml-schema keyword to obtain the most up-to-date XML schemas (.xsd files) from the router. Using this keyword is useful to prevent the use of outdated schemas in the event that router software updates include schema updates. The tar ball file includes all active schema files. It does not include schemas that are activated by specific package installation envelopes (PIEs) if those PIEs are not installed and activated on the router.
Copying to the Running Configuration
When you use the copy command to copy a configuration file to the running-config destination, the configuration in the file is applied to the running configuration of the system. This is a configuration operation. By default, the copy is carried out in a best-effort manner. This means that if some configuration lines from the file cannot be applied, the remaining configuration is still integrated into the system. In this case, a partial configuration is committed. When the atomic keyword is used, partial configurations are not committed. This means that even if one error occurs in the parsing or committing phase, no changes are made to the system. To view any errors when applying the configuration, use the show configuration failed command.
Task ID
Task ID |
Operations |
filesystem |
execute |
Examples
The following example shows how to copy a file from a FTP server to disk1:
RP/0/0/CPU0:router#
copy ftp://john:secret@10.1.1.1/images/comp-c12k-full.pie disk1:
The following example shows how to copy a file from an rcp server to disk1:
RP/0/0/CPU0:router#
copy rcp://john@10.1.1.1/images/comp-c12k-full.pie disk1:
The following example shows how to copy a file from a TFTP server to disk1:
RP/0/0/CPU0:router#
copy tftp://10.1.1.1/images/comp-c12k-full.pie disk1: