Go Premium for a chance to win a PS4. Enter to Win


Backing up Configuration settings HP-ProCurve switches'

Published on
11,898 Points
Last Modified:
This tutorial will go through the steps required to write a script that will back up the configuration settings of a HP-ProCurve switch.

You will need to get the following things to follow this tutorial:

Telnet Scripting Tool e.g. TST10.exe
Any text editing tool
TFTP Server(I am using TFTP 32 for this tutorial)
List of IP addresses for your switches

1. Installing and starting TFTP32

First thing we need to do is download the software from their web page: "http://tftpd32.jounin.net/tftpd32_download.html".  We need to download "tftpd32 standard edition (zip)".  Create a new folder and name it "SwitchesBackup" open the zip file and copy the .exe and .ini files into the folder since that's the only files we need for TFTP.

Now start the tftpd32.exe and you will be prompted with a Windows firewall warning. We need to allow it to work. After that the program should start up:You will need to save this IP.

2. Getting TST10

Next we will need TST10.exe for the Telnet connection. You can get this file at: http://jerrymannel.com/blog/2008/11/11/telnet-scripting-tool-aka-tst10exe/
scroll down and you will find the file as a .exe or zip; after downloading it place the .exe in the folder "SwitchesBackup".

3. Writing the Script

Now that we have both executables in the folder called "SwitchesBackup". We can continue and start making the script.

First of all, we need to get the IP from the TFTP32 program place the ip in "InserIPHERE".
Then we need to change %PATHHERE% at line 32 to the path you want to save the .cfg files at (the configuration backups)

I've written explanations after every line in the code to show you what the script does:
IPTftpHost = "InsertIPHERE" 'This is where the IP is declared. 
NameCMDFile = "Runbackup.cmd" 'This is the name of the command file that will be created. 

Set fso = CreateObject("Scripting.FileSystemObject") 'Scripting.FileSystemObject declare. 
Set f = fso.OpenTextFile(NameCMDFile, 2, True) 'Creating/opening the command file.
Set listFile = fso.OpenTextFile("ListSwitch.txt") 'This is the list of IP addresses of your switches'
Set shell = CreateObject("WScript.Shell") 'WScript shell declare
shell.Run """C:\Program Files (x86)\Tftpd32\tftpd32.exe""", 1, false' We start the TFTP server
Do while not listFile.AtEndOfStream 'This is the start of the loop for the file with the list of switches.
	fName =  listFile.ReadLine()'Fname is the line read from the file.
	Set filetxt = fso.CreateTextFile(fName & ".txt", True)'We create a textfile with the IP of the switch
	filetxt.WriteLine("" & _
		fName & " 23" & vbCrLf & _'Connection string
		"WAIT ""continue"""& vbCrLf & _'Waiting for Continue
		"SEND "" \m"""& vbCrLf & _'Sending nothing(Press any key to continue)
		"SEND ""copy run tftp "& IPTftpHost & " " & fName & ".cfg"""& vbCrLf & _'This is de important part, this is where you copy RUN over TFTP to your server
		"WAIT ""SW"""& vbCrLf & _'Wait for SW(This is for the switch name)
		"SEND "" \m"""& vbCrLf & _'Send nothing
		"SEND ""logout\m"""& vbCrLf & _'Send the logout command
		"WAIT ""log out"""& vbCrLf & _'Wait for log out y/n
		"SEND ""y\m"""& vbCrLf & _'Send yes
		"SEND ""n\m"""& vbCrLf & _'Send no(this must be done on some switches)
		"")'We write the telnet commands to the .txt
	filetxt.Close'We close the filestream.
	f.WriteLine("tst10 /r:" & fName & ".txt /m")'We write the command to the CMD file.
	f.WriteLine("DEL """ & fName & """.txt")'After that we write the delete command to the CMD file.
Loop'End loop
f.WriteLine("taskkill /IM tftpd32.exe")	'We kill the TFTP server
f.WriteLine("MOVE *.cfg %PATH HERE%")'We move all files with .cfg to another location.
f.close'We close the file stream.
shell.Run NameCMDFile, 1, true'We run the CMD file.
fso.deletefile(NameCMDFile)'When it's all done we delete the CMD file.

Open in new window

Now that we have the script, start it and you will see it making back-ups of your RUN configuration.
I hope you found this article helpful. And since this is my first article if you have any tips or suggestions please say so!

Administrative Comment

by:Eric AKA Netminder

Congratulations! Your article has now been published.

Page Editor

Expert Comment

What type of script is this, I named the file "ProcurveBackup.vbs and I get an invalid character error at line 14 char. 29....

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Join & Write a Comment

Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month