cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2771
Views
0
Helpful
7
Replies

Auto config backup with free tools

mikesurtees
Level 1
Level 1

Hi,

Altho there are several theads dealing with auto (sheduled or due to config changes) backups they all involve Cisco management tools.

Does anyone know if these can be done using Linux preferably or even Win2k via tftp or anything else.

Thanks in advance

Miek

1 Accepted Solution

Accepted Solutions

polifemo
Level 1
Level 1

You can use the EXPECT application, it is available for both Linux and Windows, and the scrips already exist.

View solution in original post

7 Replies 7

polifemo
Level 1
Level 1

You can use the EXPECT application, it is available for both Linux and Windows, and the scrips already exist.

Thanks for that - looks interesting.

Windows solution is Kiwi CatTools. The freeware version lets you do 5 hosts (scheduled backups but not due to configuration changes).

where can I download expect from?

Thanks

zsalb
Level 1
Level 1

Here is a script that that someone at else here improved. It uses freeware script and perl. The scripts needs to have HPOV and NNM. There are implied Perllibraries as well. You may look at the perl script that ciscoworks uses as well.

Here is the script for you to get ideas from:

#! /usr/local/bin/perl

use lib '/apps/utils/bin';

use BER '0.58';

use SNMP_Session '0.58';

use Sys::Hostname;

open (TOPODUMP, "/opt/OV/bin/ovtopodump -f Routers |") or die "cant get topodump

";

while (){

@router = split;

$flag = 1 if ($router[0] eq "NODES:");

next if ! $flag;

next if ($router[2] eq "");

$router[2] =~ s/.changetodomain.com$//i;

print "$router[2]\n";

$destFile = '/tftpboot/' . $router[2] . '-confg0';

$destFileTest = '/tftpboot/' . $router[2] . '-confg';

if (! -f $destFileTeste){

`echo test >$destFileTest`;

`/usr/bin/chmod 666 $destFileTest`;

}

if (! -f $destFile){

`echo test >$destFile`;

`/usr/bin/chmod 666 $destFile`;

`echo test >$destFileTest`;

`/usr/bin/chmod 666 $destFileTest`;

system ("/opt/OV/bin/snmpset -t 50 -c \writecommunitystring -r5 $router[2] .

1.3.6.1.4.1.9.2.1.55.131.219.234.134 octetstring $router[2]-confg0");

print"/opt/OV/bin/snmpset -t 50 -c \writecommunitystring -r5 $router[2] .1.3

.6.1.4.1.9.2.1.55.131.219.234.134 octetstring $router[2]-confg0\n";

}else

{

system ("/opt/OV/bin/snmpset -t 50 -c \writecommunitystring -r5 $router[2] .

1.3.6.1.4.1.9.2.1.55.131.219.234.134 octetstring $router[2]-confg");

print "/opt/OV/bin/snmpset -t 50 -c \writecommunitystring -r5 $router[2] .1.

3.6.1.4.1.9.2.1.55.131.219.234.134 octetstring $router[2]-confg\n";

my $diff = `diff $destFile $destFileTest`;

if ($diff ne ""){

&rotate($destFileTest, $router[2]);

}else{

print "xx cp $destFileTest $destFile\n";

system("cp $destFileTest $destFile");

}

}

}

sub rotate {

my $file = shift;

my $router = shift;

&sendtrap($router);

my $count = 10;

while ($count > 0){

my $fromFile = $file . ($count - 1);

my $toFile = $file . $count;

if ( -f $fromFile){

print "aa cp $fromFile $toFile\n";

system("cp $fromFile $toFile");

}

$count--;

}

my $fromFile = $file;

my $toFile = $file . $count;

if ( -f $fromFile){

print "zz cp $fromFile $toFile\n";

system("cp $fromFile $toFile");

}

}

sub sendtrap{

$hostname = shift;

my $myIpAddress = gethostbyname($hostname);

{ @bytes = unpack("C4", $myIpAddress);

shift @bytes while @bytes && $bytes[0] == 0;}

my $trap_receiver = "127.0.0.1";

my $trap_community = "publiccommunity string";

my $trap_session = SNMP_Session->open ($trap_receiver, $trap_community, 162);

my $start_time = time;

my $genericTrap = 6; # Enterprise Specific

my $specificTrap = 0;

my $upTime = 0;

my @myOID = ( 1,3,6,1,3,5000,3,1 );

push @VarBinds, ([encode_oid (@myOID), encode_string ($hostname)]);

push @VarBinds, ([encode_oid (@myOID), encode_string ("The configuration on $hos

tname has changed")]);

$trap_session->trap_request_send (encode_oid (@myOID),

encode_ip_address ($myIpAddress),

encode_int ($genericTrap),

encode_int ($specificTrap),

encode_timeticks ($upTime),

@VarBinds

) ;

}

exit;

Thanks,

Ive been getting a few resonses to my question so a few avenues to explore. I have handed the script over to a collegue who knows far more about Perl than I do, but we do have HP-OV and NNM so could prove very useful.

Will probably now need to ask a question re:

VPN concentrators backup and up/down monitoring of LAN-LAN IPsec tunnels. But that need it's own thread probably.

Thanks again

Glad to be of help on my own behalf and my collogues who contributed to the script.

Review Cisco Networking for a $25 gift card