Switches, Hubs, and Modems
cancel
Showing results for 
Search instead for 
Did you mean: 

ProCurve Configuration Backup Automation Script

Anis Kochlef
Occasional Visitor

ProCurve Configuration Backup Automation Script

How to automate HP ProCurve configuration backups using Perl and SNMP

Prerequisite

- Perl
- Net-SNMP
- Net-TFTP

The script:
-----------

use Net::TFTP;

@ip = ("192.168.16.120","192.168.16.29","192.168.16.108");
$number_of_ips = @ip;
$community = "private";


($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
for ($i=0 ; $i < $number_of_ips ; $i++)
{
$filename=sprintf ("%s-%02d%02d%02d%02d%02d.cfg",$ip[$i],$year-100,$mon+1,$mday,$hour,$min);


$cmd = "snmpset -v2c -c $community $ip[$i] .1.3.6.1.4.1.11.2.14.11.5.1.7.1.5.6.0 i 2";
if(system($cmd)) { die "Can't Connect to $ip[$i] via SNMP \n" ;}

$tftp = Net::TFTP->new($ip[$i], BlockSize => 1024);
$tftp->ascii;
$tftp->get("startup-config", $filename);

$cmd = "snmpset -v2c -c $community $ip[$i] .1.3.6.1.4.1.11.2.14.11.5.1.7.1.5.6.0 i 1";
if(system($cmd)) { die "Can't Connect to $ip via SNMP \n" ; }
}