Operating Broadband Network Gateway (BNG)

For many years I maintained a Juniper ERX1410 running JUNOSe. Over time I created a backup script in 2007 that would allow me to initiate a backup of the broadband router and move on to another task while the backup job processed.

An E Series router has an embedded macro language that enables you to define and run macros that can generate and execute CLI commands. Macro files—identified by the .mac extension—can be used to store more than one macro. Depending on your needs, you might want to store all of your macros in one file, group macros by function, or store only one macro per file.

– Juniper documentation

Backup Types

JUNOSe can provide two backup files; a human-readable text with an .SRC extension and the binary type is a .CNF. It can move these files to a remote server using the FTP protocol.
The JUNOSe macro script can reside on the local router, or it can reside on a remote FTP server. JUNOSe allows executing the macro script from a local filesystem or a remote system over the FTP protocol (Kind-a cool).

The CLI command sets used in the macro script are the following,

!
copy running-configuration backupfile.cnf
show running-configuration > backupfile.scr
!
copy backupfile.cnf ftp:backupfile.cnf
copy backupfile.scr ftp:backupfile.scr
!

In the above, you will see the “…ftp:backupfile.cnf”; it should raise a question as to how the ERX knows what host to use since there is no DNS name or IP address defined. Before the above can be used, a static host entry must be created for the FTP destination. Here is an example of what that would look like,

!
host ftp 192.168.1.1 ftp user1 user1pass
!

The command breakdown: host <ID DESC> <IP ADD> <PROTOCOL> <USER> <PASS>

Vendor Documentation

Here’s the product reference

http://www.juniper.net/us/en/products-services/routing/e-series/

Here’s the documentation for the E-Series

http://www.juniper.net/techpubs/software/erx/

Script Example

Here is the script I used running JUNOSe version 6.x on an ERX1410 platform.

<# start #>
<# setoutput console #>

***********************************************************************
Name: Configuration Backup Macro
File Name: run_backup_rtrname.mac
Version: 0.1.0
Created By: Jeff Neuffer Jr
Created On: 6/12/2007
Last Modified: $Id$
Description: Used for backing up JUNOSe to .scr and .cnf and
making a copy of the backup files by placing those
files on a remote FTP server
***********************************************************************
<# endsetoutput #>

<# file_name := "rtrname" #>

<# setoutput console #>

Requesting .CNF file

<# endsetoutput #>

copy running-configuration <# file_name #>.cnf

<# setoutput console #>

Requesting .SRC file

<# endsetoutput #>

show configuration > <# file_name #>.scr

<# setoutput console #>

Sending both files to FTP Server

<#endsetoutput #>

copy <# file_name #>.cnf ftp:<# file_name #>.cnf
copy <# file_name #>.scr ftp:<# file_name #>.scr

<# setoutput console #>

Done with Sending both files to FTP Server.
Calling up local flash filesystem to see
that the file timestamps match today's time
of backup.

<#endsetoutput #>
show clock
terminal length 0
dir

<#endtmpl#>

Run the Script

host1(config)#macro run_backup_rtrname.mac

Describing how to run the script from the ERX was missing in the original post of this document. In a separate blog post, it was added.


DOCUMENT REVISION

REVISION DATEREVISION COMMENT
2022-11-05Updated document formatting from WordPress “classic” to “block”.
Fixed formatting of macro script.
Added a statement describing how to execute the script. This was missing from the original write-up.
Added section headings.
Gramatical corrections.

    Last modified: 11/05/2022

    Comments

    Hi. Thank you for the valuable information. Please let me know if it is possible to copy the running-configuration as .scr file to local storage. Kindly share your thoughts.

      Hi Jayashree, Thank you for posting the question. When discussing local storage there are two contextual perspectives that come to mind when using the CLI. 1) Local storage on the ERX 2) Local storage in relation to the management terminal session A configuration .src file can be saved to the ERX’s local file system as seen in the above macro script (#1 above). Configuration files can also be directly saved to a remote system via two transfer protocols (FTP and TFTP) from version 6.x. Presuming the management terminal session is also providing FTP/TFTP services, and then it is possible to save the .scr configuration directly (#2 above). In the past though, I personally saved the configurations to a purposed platform for archiving. It was from archive system that I would then transfer a configuration to my local workstation for any kind of work. SFTP can be used to copy files too, however it does have limited functionality. JUNOSe also supports the role of an NFS client, however this functionality is not implemented in a manner that provides mounting/un-mounting of files via the CLI. Here is a reference to specifics of what is mentioned above; chapter “Managing the System” in the “JunosE 14.3.x System Basics Configuration Guide”. https://www.juniper.net/techpubs/en_US/junose14.3/information-products/topic-collections/swconfig-system-basics/index.html

    Thanks for such helpful post. I wanted to check whether you used some variable to append in the file name.

      Uniqueness is paramount in the context of backups, so yes I did use a variable which was equal to the date with time stamp. This was performed by the calling method (script) of the macro. If you mean to ask if I used an [ARG] value to the script, no.

    Write a Reply or Comment