The following scripts which I run on linux will backup the configurations of CatOS and IOS based switches to the tftp server on the linux host using SNMP.
1) The CatOS version
#!/bin/bash
# This script uses SNMP to download the configuration of the CatOS
# switches, via tftp to the /tftpboot directory
#
# This version (see also saveconfig) operates based on
# the CISCO-STACK-MIB and applies to modules running the Catalyst
# Operating System (OS)
#
# Gavin Newman
#
# The production version of this script exists in the /home/root
# directory and is run via a cron job or as required
switches="switch1 switch2 switch3"
datestamp=`date +%Y%m%d`
oidCisco=.1.3.6.1.4.1.9.5.1.5
oidServer=$oidCisco.1.0
oidFilename=$oidCisco.2.0
oidModule=$oidCisco.3.0
oidAction=$oidCisco.4.0
community=xyzxyz
echo Downloading Cisco switch configurations $datestamp
for switch in $switches; do
echo -n $switch
snmpset $switch $community $oidServer s tftp_server_ip_address > /dev/null
snmpset $switch $community $oidFilename s $switch.config > /dev/null
snmpset $switch $community $oidModule i 1 > /dev/null
snmpset $switch $community $oidAction i 3 > /dev/null
r=$(snmpget -Ov $switch public $oidCisco.5.0)
while [ "$r" = "1" ]; do
echo -n .
sleep 1
r=$(snmpget -Ov $switch public $oidCisco.5.0)
done
case $r in
2) echo Success ;;
3) echo No response ;;
4) echo Too many retries ;;
5) echo No processes ;;
6) echo No buffers ;;
7) echo Bad checksum ;;
8) echo Bad Length ;;
9) echo Bad Flash ;;
10) echo Server Error ;;
11) echo User cancelled ;;
12) echo Wrong code ;;
13) echo File not found ;;
14) echo Invalid TFTP host ;;
15) echo Invalid TFTP module ;;
16) echo Access violation ;;
17) echo Unknown status ;;
18) echo Invalid storage device ;;
19) echo Insufficient space on storage device ;;
20) echo Invalid DRAM size ;;
*) echo Some sort of error - return code is $r ;;
esac
done
echo Download Completed
2) The IOS version
#!/bin/bash
# This script uses SNMP to download the configuration of the IOS based
# switches, via tftp to the /tftpboot directory
#
# Gavin Newman
#
# This version (see also savecat) implements CISCO-CONFIG-COPY-MIB
# and applies to modules running the Cisco IOS Release 12.0 or later
# software.
#
# The production version of this script exists in the /home/root
# directory and is run via a cron job or as required
datestamp=`date +%Y%m%d`
echo Downloading Cisco MSF module configurations $datestamp
oidCisco=.1.3.6.1.4.1.9.9.96.1.1.1.1
oidProtocol=$oidCisco.2
oidSource=$oidCisco.3
oidDest=$oidCisco.4
oidServer=$oidCisco.5
oidFilename=$oidCisco.6
oidStatus=$oidCisco.14
oidCopyState=$oidCisco.10
oidCopyFailCause=$oidCisco.13
routers="switcha switchb switchc"
community=xyzxyz
for router in $routers; do
s=$RANDOM
echo -n $router
snmpset $router $community $oidProtocol.$s i 1
snmpset $router $community $oidSource.$s i 4
snmpset $router $community $oidDest.$s i 1
snmpset $router $community $oidServer.$s a tftp_host_ip_address
snmpset $router $community $oidFilename.$s s $router.config
snmpset -Ir $router $community $oidStatus.$s i 1
r=$(snmpget -Ov $router $community $oidCopyState.$s)
sleep 1
# May be waiting for another copy to complete
while [ "$r" = "1" ]; do
echo -n w
sleep 1
r=$(snmpget -Ov $router $community $oidCopyState.$s)
done
# Wait for copy to complete
while [ "$r" = "2" ]; do
echo -n .
sleep 1
r=$(snmpget -Ov $router $community $oidCopyState.$s)
done
case $r in
3) echo Success ;;
4) err=$(snmpget -Ov $router $community $oidCopyFailCause.$s)
case $err in
1) echo Unknown reason for failure ;;
2) echo Bad file name, path or permissions ;;
3) echo Timeout. Network load or TFTP server is not responding ;;
4) echo Memory allocation failure ;;
5) echo Could not find the requested configuration ;;
*) echo Undocumented failure code $err received ;;
esac ;;
*) echo Unknown completion status $r ;;
esac
done
echo Download Completed
Hope this helps