Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pulling configs to a unix station as a backup 1

Status
Not open for further replies.

AidanEnos

MIS
Dec 11, 2000
189
Okay,

I have a unix station on my network, I have a read write community sting and all passwords.

I want to create a script for my C5***'s to backup all of my configs as an executable then schedule it to automatically run.

Can anyone help in getting this going? Basically I want it to basically do...

connect c5505-123
bin
get Config c5505-123
quit

next...

then I can do all the rest, with mocing the files and stuff but how do I get the configs? Would I use the mib variable, if so what is it and what is the command line to retrieve it? Or would I use a tftp command if so what is that?

AidanEnos
 
There's a command set in the switch IOS depending on what version you have to execute remote shell like (RSH) commands. To just simply copy the configs and image file log in, and do a copy (from) (to) "copy startup-config tftp://hostaddress/config-name"


Joe
 
I know how to do:

copy run tftp
copy config tftp

I want to do it from a unix station on the network and NOT have to log into my 60 switches (enable mode) to backup the configs.

I know it can be done, i'll figure it out... please make my life easy!
 
if you have SNMP on your Unix box (most do, or there are loadsa freeware)
try using from your unix machine...

snmpset -c <read community string> <device name> .1.3.6.1.4.1.9.2.1.55.194.33.111.100 octetstring <filename on unix box>

(all one command)

I have a script which uses this command, checks if the config has changed since the last time and if it has it mails me with the changes.
 
does the string you identified have your nodal ip address in it?

194.33.111.100

how can I get a look at that script since it seems to be exactly what I'm looking for :eek:)

 
Hi Aidan..

the script is below. you will have to change some of the directories, but it's not a complex script.

Good luck, let me know how you get on with it.

PS. you may like also to look at KIWI SOFT Cat Tools.

I'm just starting to get into it and it looks pretty fly.

# 01/11/00
# This script retrieves router configurations and reports
# if any changes have been made since the last time a
# config was retrieved.
# It is normally executed by cron, once a month to keep
# the configuration database up to date.
# It can be run on an ad hoc basis to update the config d/b
# after any changes have been made.
# Use the extension CHANGE and follow the on screen prompts
# to update manually.
# Written by Phil Gregory. Lead Technician GPU Power UK
# phil.gregory@gpupower.co.uk
# This script may be distributed within GPU Power as long as the above
# message is kept intact.
#
bindir=/usr/OV/bin
changed=NO
maillist=&quot;PUT EMAIL ADDRESSES HERE&quot;

function getconfig {
rm $fname
touch $fname
chmod 666 $fname
$bindir/snmpset -c <READ COMMUNITY> $rname .1.3.6.1.4.1.9.2.1.55.IP.ADDRESS.OF.UNIX.BOX octetstring $fname
}

function haschanged {
difference=$(diff $fname /usr/OV/log/routers/$rname-current)
if [ &quot;$difference&quot; = &quot;&quot; ]
then
changed=NO
else
changed=YES
fi
}

function backupcfg {
timestamp=$(date +&quot;%H%M%d%m%y&quot;)
cp /usr/OV/log/routers/$rname-current /usr/OV/log/routers/$rname.b4.$timestamp
cp $fname /usr/OV/log/routers/$rname-current
}

function reportdifferences {
echo &quot;$message&quot; > /tmp/diff.report
diff $fname /usr/OV/log/routers/$rname-current >> /tmp/diff.report
mail -s &quot;$subject&quot; $maillist < /tmp/diff.report
}

function copytoftp {
cp /usr/OV/log/routers/$rname-current /u/ftp/log/routers/$rname-current
chmod a+r /u/ftp/log/routers/$rname-current
}

# if the command is entered as rconfig CHANGE rcn then just update the config
# for the router spec'd and notify the maillist of the changes

if [ &quot;$1&quot; = &quot;CHANGE&quot; ]
then
clear
banner WARNING
echo &quot;THE COMMAND YOU HAVE ENTERED WILL UPDATE
THE CONFIGURATION DATABASE.

NOTIFICATION OF THE CHANGES WILL BE SENT TO
$maillist

Please confirm you are sure by entering YES&quot;
read sure
if [ $sure = &quot;YES&quot; ]
then
echo &quot;Please enter the hostname of the router
where configuration changes have been made&quot;
read rname
fname=/tmp/$rname-confg
subject=&quot;Recorded/Authorised configuration change on router $rname&quot;
message=&quot;The following changes were made on router $rname&quot;
getconfig
reportdifferences
backupcfg
copytoftp
fi
else
cat /etc/router.list |while read rname
do
fname=/tmp/$rname-confg
getconfig
haschanged
if [ &quot;$changed&quot; = &quot;YES&quot; ]
then
subject=&quot;UNRECORDED changes found on Router $rname&quot;
message=&quot;The following UNRECORDED/UNAUTHORISED changes have been made on router $rname&quot;
reportdifferences
backupcfg
copytoftp
fi
done
fi
 
for this script to work automatically you need a list of the routers you wish to monitor in a file called /etc/router.list
and then call the script from cron.
 
I've read it many times, and it's over my head. I'm not a programmer so I think I'm gonna have a tough time implementing a script that is so complex...

can you make it a little more basic and simply answer my original question:

what is the snmpget string for a Catalyst configuration file? or do I have to do a series of set commands to make this work?

is there a tftp get config command that will work?
 
OK, the set command you need is...
&quot;snmpset -c <READ COMMUNITY> <device name> .1.3.6.1.4.1.9.2.1.55.IP.ADDRESS.OF.UNIX.BOX octetstring <file name on unix box>&quot;

Cheers,
Phil.
 
octetstring what data are you looking to fill in there?

 
octetstring just tells the SNMP agent that the value that follows is of type octetstring. so just type it as part of the command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top