I really like using Perl because of the Net-SNMP Perl libraries that make it really easy to write code to interact with devices that support SNMP.
Hopefully everyone out there is backing up their network switch configurations in the unlikely event that if their hardware dies they only need to worry about replacing the hardware and not about re-configuring the entire switch.
Quite a few years back I wrote a Perl script that would send the proper SNMP commands to instruct a network switch to copy it’s configuration to a TFTP server. This script essentially became known as “switchtftpbackup.pl” It’s nothing fancy or pretty but it gets the job done.
I’ve posted this Perl script on my webiste under the Perl section.
I run this script from Cron one of our CentOS Linux servers at work every week. The same server also acts as a central TFTP server for the entire organization. I also run other scripts that then archive the weekly backups, in the event that I need to go to a backup that’s more than a week old.
I believe both Nortel’s Optivity NMS and Cisco’s Cisco Works both have options to backup switch configurations these days.
What are you using?
Cheers!
Roderick says
Me, lazy network engineer, I am looking for an automated way to backup my Nortel switches and routers. I am going to check your script and see if I can use it. Seems very promising to backup my configs using SNMP.
Thnx in advance.
REYNAUD Guillaume says
Hello,
(Excuse me for my bad english, i’am french). I would like use your script but when I launch this is error message :
“error: set: unknown object ID (s5AgMyIfLdSvrAddr) at /usr/lib/perl5/SNMP.pm line 617.
ERROR: {BayStack} problem setting the TFTP parameters for 192.168.0.140
ERROR: {BayStack} sess->{ErrorStr} = Unknown Object Identifier
error: set: unknown object ID (s5AgInfoFileAction) at /usr/lib/perl5/SNMP.pm line 617.
ERROR: {BayStack} problem setting the TFTP action bit for 192.168.0.140
ERROR: {BayStack} sess->{ErrorStr} = Unknown Object Identifier
error: get: unknown object ID (s5AgInfoFileStatus) at /usr/lib/perl5/SNMP.pm line 638.
ERROR: problem checking the TFTP result for 192.168.0.140
ERROR: sess->{ErrorStr} = Unknown Object Identifier
DEBUG: unknown error return = DEBUG: upload config file results = ”
Please help me.
PS: I use an ubuntu V9.04 with snmp and perl V5.1
A+.
Michael McNamara says
Hi Reynaud,
Your English is fine… it looks like you’re missing the vendor specific MIBS. You need to install the vendor specific MIBS, usually in /usr/share/snmp/mibs.
In your specific case you need the s5age156.mib (S5-AGENT-MIB). If your not familiar with SNMP MIBS you’ll need to know that that MIB has dependencies on other SNMP MIBS, specifically S5-ROOT-MIB and S5-TCS-MIB although there may be other dependencies.
I have a tar archive of all the SNMP MIBS on my CentOS server here.
Good Luck!
Updated: August 24, 2009 – fixed broken link
REYNAUD Guillaume says
Thanks, but your link is down.
A+ Guillaume.
Michael McNamara says
I’ve fixed the link.
Cheers!
REYNAUD Guillaume says
Hello,
Thanks for this file, I have installed your files and when I lauch your script, this is an error message :
“root@LML4:/home/administrateur/temp# ./backup
Read ALL
DEBUG: the filename for 192.168.0.140 will be 192-168-0-140.cfg
DEBUG: I’m touching the following file /tftpboot/192-168-0-140.cfg
DEBUG: I’m chaning the permissions on /tftpboot/192-168-0-140.cfg
DEBUG: snmphost = 192.168.0.140 and community = public
DEBUG: 192.168.0.140 sysObjectID=sreg-BayStack470-48T-ethSwitchNMM
DEBUG: sysObjectID = sreg-BayStack470-48T-ethSwitchNMM (192.168.0.140)
test: sreg-BayStack470-48T-ethSwitchNMM
ERROR: {BayStack} problem setting the TFTP parameters for 192.168.0.140
ERROR: {BayStack} sess->{ErrorStr} = (noSuchName) There is no such variable name in this MIB.
ERROR: {BayStack} problem setting the TFTP action bit for 192.168.0.140
ERROR: {BayStack} sess->{ErrorStr} = (noSuchName) There is no such variable name in this MIB.
DEBUG: 192.168.0.140 was successful
DEBUG: upload config file results = success”
Good Luck! Guillaume.
Michael McNamara says
What version of software is the switch running?
Also it’s probably an issue with the MIB files. I would suggest you backup the files in the MIBS folder and then delete all of them. Then explode the MIB archive that I provided, you are using the SNMP read-write community string correct?
Good Luck!
Guillaume says
Hello, thanks for this reponse.
My Model : BayStack470-48T
My version of switch is : FW:2.2.01 / SW:2.2.0.14
My default community read is public
My default community write is private
Good luck. Guillaume
REYNAUD Guillaume says
I solve my problem, The problem is the community. By default in the script the community is public for read. I change to private and it’s OK.
Very thanks for this support.
1) I’am a blog http://quick-tutoriel.com, and I would like this script modified to my blog with explications. Your ok ?
2) I would like add your blog in my links section, your are ok ? if ok you can add my address site in your links section ?
A+ Guillaume
Michael McNamara says
Hi Reynaud,
I’m happy to hear that you were able to get things working.
You may modify the script so long as the code references the originating author, myself, and either this blog or my website. Beyond that you may adopt the code however you feel fits your needs.
You may add a link to this blog wherever you feel useful and/or appropriate.
Good Luck!
Stefan Nistelberger says
Hi guys, I’ve also written a backup script for nortel devices some time ago.
http://scuq.abyle.org/?page_id=187