This article describes a script, which will collect the configuration of E Series routers and upload it to an FTP server for backup. This script will also provide E Series customers that require automatic backups with the ability to customize the frequency at which the backup occurs. The script can save both a binary and text version of the configuration.
Automation Procedure
The steps required for automating the configuration backup activity are as follows:
- Create a macro file (*.mac extension).
-
Copy and past script into macro.
- Create FTP host:
host <FTP server name> <FTP server IP address> ftp <username> <password>
- Save file to SRP disk0:
copy <FTP server name>:/<# macro file name #>.mac <# macro file name #>.mac
- Verify transfer was successful:
dir disk0:<# macro file name #>.mac
- Configure the frequency at which the macro should run:
schedule macro interval frequency <value in minutes> <# macro file name #>.mac
- Verify configured schedule:
show
schedule macro
Customizable script
Here is a template script that can be customized to automate configuration backup activities.
// Script //
<# start #>
<# env.startCommandResults #>
show clock
<# env.stopCommandResults #>
<# date := env.getResults #>
<# date1 := substr (date, 0, 15) #>
<# month := substr (date, 4, 3) #>
<# day := substr (date, 8, 2) #>
<# year := substr (date, 11, 4) #>
<# file_name := "BSR-E320-1" $ day $ mahina $ year #>
<# setoutput console #>
File name is <# file_name #>
Requesting .CNF file
<# endsetoutput #>
copy running-configuration <# file_name #>.cnf
<# setoutput console #>
Requesting .SCR file
<# endsetoutput #>
show configuration > <# file_name #>.scr
<# setoutput console #>
Sending both files to FTP Server
<#endsetoutput #>
copy <# file_name #>.cnf ftpserver:/juniper/eseries/<# file_name #>.cnf
copy <# file_name #>.scr ftpserver:/juniper/eseries/<# file_name #>.scr
<# setoutput console #>
Done
<#endsetoutput #>
show clock
<#endtmpl#>