<

Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

Backing up Configuration settings HP-ProCurve switches'

Published on
11,797 Points
5,797 Views
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!
0
Comment
Author:DAlper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
 

Administrative Comment

by:Eric AKA Netminder
DAlper,

Congratulations! Your article has now been published.

ericpete
Page Editor
0
 
LVL 1

Expert Comment

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

Featured Post

ATEN's HDBaseT Presentation at InfoComm 2017

Hear ATEN Product Manager YT Liang review HDBaseT technology, highlighting ATEN’s latest solutions as they relate to real-world applications during her presentation at the HDBaseT booth at InfoComm 2017.

Join & Write a Comment

In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month