Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Junos CLI Reference
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

file archive

date_range 19-Nov-23

Syntax

content_copy zoom_out_map
file archive destination destination source source
<compress>
<exclude> filepattern
<routing-instance>
<source-address>

Description

Archive, and optionally compress, one or multiple local system files as a single file, locally or at a remote location.

For information on valid filename and URL formats, see Format for Specifying Filenames and URLs in Junos OS CLI Commands.

Options

destination destination

Destination of the archived file or files. Specify the destination as a URL or filename. The Junos OS adds one of the following suffixes if the destination filename does not already have it:

  • For archived files—The suffix .tar

  • For archived and compressed files—The suffix .tgz

source source

Source of the original file or files. Specify the source as a URL or filename.

compress

(Optional) Compress the archived file with the GNU zip (gzip) compression utility. The compressed files have the suffix .tgz.

exclude (Optional) Specify the file pattern to exclude. exclude helps to exclude files that delay compression or files that need not be compressed.
routing-instance routing-instance-name (Optional) Name of the routing-instance.
source-address address (Optional) Local address to use in originating the connection.

Required Privilege Level

maintenance

Output Fields

When you enter this command, you are provided feedback on the status of your request.

Sample Output

file archive (Multiple Files)

The following sample command archives all messages files in the local directory /var/log/ as the single file messages-archive.tar.

content_copy zoom_out_map
user@host> file archive source /var/log/messages* destination /var/log/messages-archive.tar
/usr/bin/tar: Removing leading / from absolute path names in the archive.

user@host> 

file archive (Single File)

The following sample command archives a single messages file in the local directory /var/log/ as the single file messages-archive.tar.

content_copy zoom_out_map
user@host> file archive source /var/log/messages destination /var/log/messages-archive.tar
/usr/bin/tar: Removing leading / from absolute path names in the archive.

user@host> 

file archive (with Compression)

The following sample command archives and compresses all messages files in the local directory /var/log/ as the single file messages-archive.tar.

content_copy zoom_out_map
user@host> file archive compress source /var/log/messages* destination /var/log/messages-archive.tgz
/usr/bin/tar: Removing leading / from absolute path names in the archive.
user@host> 

File Archive Using Secure Copy Protocol (scp) with ’source-address’ and ’routing-instance’ options

To use the scp command to archive a file with the source-address and routing-instance options, enter the following command:

content_copy zoom_out_map
user@host> file archive source source destination scp:// destination source-address address routing-instance instance-name

File Archive Compress (with Exclude Option)

The following sample command archives and compresses all messages files in the local directory /var/log/ and excludes the single file pattern specified.

content_copy zoom_out_map
user@host>file archive compress source /var/log destination /var/tmp/sample exclude trace*
/bin/tar: Removing leading `/' from member names
/bin/tar: /var/log/journal/dbf38b9cae4d11ec862e4fb4fcef8787/system.journal: file changed as we read it

Release Information

Command introduced before Junos OS Release 7.4.

exclude option added in Junos OS Release 20.3R1 and Junos OS Evolved Release 20.3R1.

routing-instance option added in Junos OS Release 18.4R1.

source-address option added in Junos OS Release 18.4R1.

footer-navigation