Archiving files in Juniper SRX devices
The operational "> file archive" Junos command will archive files and compress them optionally.
Although the output of following command shows the current working directory for the user:
Code:
user@srx-220> file archive compress source ?
Possible completions:
<source> Path of directory to archive
COS-config.conf Size: 151632, Last changed: Apr 16 15:30:14
The actual command does not use the same directory. Example:
Code:
user@srx-220> file archive compress source COS-config.conf destination COS-config.conf.tgz
/usr/bin/tar: COS-config.conf: Cannot stat: No such file or directory
/usr/bin/tar: Error exit delayed from previous errors
user@srx-220> file archive compress source COS-config.conf destination COS-config.conf.tgz | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/12.1X44/junos">
<output>
/usr/bin/tar: COS-config.conf: Cannot stat: No such file or directory
/usr/bin/tar: Error exit delayed from previous errors
</output>
<rpc>
<file>
<file-fetch>
<source-filename>/var/tmp//COS-config.conf.tgz3sFg</source-filename>
</file-fetch>
</file>
</rpc>
<rpc>
<file>
<file-put>
<source-filename>/var/tmp//COS-config.conf.tgz3sFg</source-filename>
<destination-filename>COS-config.conf.tgz</destination-filename>
</file-put>
</file>
</rpc>
<cli>
<banner></banner>
</cli>
</rpc-reply>
So the actual directory by the "file archive" command to find the source file is "/var/tmp/".
Instead, use absolute paths to the source and destination files:
Code:
user@srx-220> file archive compress source /cf/var/home/user/COS-config.conf destination /cf/var/home/user/COS-config.conf.tgz
/usr/bin/tar: Removing leading `/' from member names
I will open a PR with Juniper engineering soon (can't commit on a date).