Copying files

Use the copy command to upload or download an image file, configuration file, or other file types to or from a flash device or an FTP/TFTP server.

The copy command supports wildcards.

Use the recursive keyword to recursively copy files and directories. If files or directories already exist, the operator is prompted to overwrite them. When the force keyword is specified, a positive response to the overwrite prompts is assumed. The operator is not prompted for confirmation and the existing files or directories are overwritten.

The scp command copies files between hosts on a network. It uses SSH for data transfer, and uses the same authentication and provides the same security as SSH.

The source file for the scp command must be local. The file must reside on the router. The destination file has to be of the format: user@host:file-name. The destination does not need to be local.

# file> 
    # copy <source-file-url> <dest-file-url> [force][no-redirect][client-tls-profile <tls-profile-name>][proxy <proxy-url>] [recursive]
    # scp <local-file-url> <destination-file-url> [router <router-instance>][force]
    # scp <local-file-url> <destination-file-url> [force] service <service-name>

The following displays examples of the command syntax:

A:node-2>file cf3:\ # copy 104.cfg cf1:\test1\test2\test3\test.cfg

A:node-2>file cf3:\ # scp file1 admin@192.168.0.1:cf1:\file1

A:node-2>file cf3:\ # scp file2 user2@192.168.0.1:/user2/file2

A:node-2>file cf3:\ # scp cf2:/file3 admin@192.168.0.1:cf1:\file3

The following example displays a recursive directory copy:

A:node-2# file dir
Volume in drive cf3 on slot A is SROS VM.

Volume in drive cf3 on slot A is formatted as FAT32

Directory of cf3:\

09/19/2021 06:11p 196 BOF.CFG
09/19/2021 06:11p 0 CONFIG.CFG
09/19/2021 06:11p 101 NVRAM.DAT
09/19/2021 07:22p SUPPORT/
09/19/2021 06:11p SYSLINUX/
09/19/2021 06:11p TIMOS/
09/23/2021 09:03a 27459 bootlog.txt
09/20/2021 09:56a 27326 bootlog_prev.txt
09/23/2021 01:21p 319 nvsys.info
09/21/2021 07:19p recursive3/
09/23/2021 08:22a ssh/
7 File(s) 55402 bytes.
6 Dir(s) 612319232 bytes free.

A:node-2# file dir recursive3

Volume in drive cf3 on slot A is SROS VM.

Volume in drive cf3 on slot A is formatted as FAT32

Directory of cf3:\recursive3

09/21/2021 07:18p ./
09/21/2021 07:18p ../
09/21/2021 07:19p 7 file1.txt
09/21/2021 07:19p recursive2/
1 File(s) 7 bytes.
3 Dir(s) 612319232 bytes free.

A:node-2# file copy recursive3 recursive1 recursive
Copying directory cf3:\recursive3
Copying directory cf3:\recursive3\recursive2
Copying file cf3:\recursive3\recursive2\file2.txt ... OK
Copying file cf3:\recursive3\recursive2\file3.txt ... OK
Copying file cf3:\recursive3\file1.txt ... OK
2 dir(s) and 3 file(s) copied.
A:sros# file dir
Volume in drive cf3 on slot A is SROS VM.

Volume in drive cf3 on slot A is formatted as FAT32

Directory of cf3:\

09/19/2021 06:11p 196 BOF.CFG
09/19/2021 06:11p 0 CONFIG.CFG
09/19/2021 06:11p 101 NVRAM.DAT
09/19/2021 07:22p SUPPORT/
09/19/2021 06:11p SYSLINUX/
09/19/2021 06:11p TIMOS/
09/23/2021 09:03a 27459 bootlog.txt
09/20/2021 09:56a 27326 bootlog_prev.txt
09/23/2021 01:21p 319 nvsys.info
09/23/2021 02:42p recursive1/
09/21/2021 07:19p recursive3/
09/23/2021 08:22a ssh/
7 File(s) 55402 bytes.
7 Dir(s) 612298752 bytes free.

A:node-2# file dir recursive1

Volume in drive cf3 on slot A is SROS VM.

Volume in drive cf3 on slot A is formatted as FAT32

Directory of cf3:\recursive1

09/23/2021 02:42p ./
09/23/2021 02:42p ../
09/23/2021 02:42p 7 file1.txt
09/23/2021 02:42p recursive2/
1 File(s) 7 bytes.
3 Dir(s) 612298752 bytes free.