03-03-2016 05:13 AM
Hello,
I have tested a script to backup the config from a SG300-10 switch but the script are not working.
I tested with plink, but I can connect to the switch but the command is not running.
Have someone a working script to backup the configuration from am Small Business Switch
I have over 20 SG300-10 and I want backup the config from time to time from all switches.
Have someone a working script where I can use?
Many Thanks for the help
Regars Markus
03-29-2016 08:45 AM
linux shell script, requires the Cisco Small Business MiB:
#!/bin/bash
host=$1
string='secret'
mib=/usr/share/snmp/mibs/CISCOSBcopy.mib
case $2 in
start | startup | startup_config )
rlCopySourceFileType="3" #3 for startup config, 2 for running config
filename=$host\_$(date +%b.%d.%Y)_startup_config.txt
;;
run | running | running_config )
rlCopySourceFileType="2" #3 for startup config, 2 for running config
filename=$host\_$(date +%b.%d.%Y)_running_config.txt
;;
* | "" | -h | --help | usage | --usage )
echo "you must specify 2 parameters, host and config"
echo ""
echo "host would be the name of a switch that is to be backed up, sg300 or sg500"
echo "config would be the name of the config to be backed up, running_config or startup_config"
exit
;;
esac
rlCopyRowStatus="4" #create and go
rlCopySourceLocation="1" #local
rlCopySourceIpAddress="0.0.0.0"
rlCopySourceUnitNumber="1" #unit number in stack
rlCopySourceFileName="" #blank
rlCopyDestinationLocation="3" #tftp
rlCopyDestinationIpAddress="192.168.88.1" #tftp server ip
rlCopyDestinationUnitNumber="1" #unit number in stack
rlCopyDestinationFileName=$filename
backup (){
snmpset -v2c -c $string -m +/usr/share/snmp/mibs/CISCOSBcopy.mib $host \
rlCopyRowStatus.0 i $rlCopyRowStatus \
rlCopySourceLocation.0 i $rlCopySourceLocation \
rlCopySourceIpAddress.0 a $rlCopySourceIpAddress \
rlCopySourceUnitNumber.0 i $rlCopySourceUnitNumber \
rlCopySourceFileType.0 i $rlCopySourceFileType \
rlCopyDestinationLocation.0 i $rlCopyDestinationLocation \
rlCopyDestinationIpAddress.0 a $rlCopyDestinationIpAddress \
rlCopyDestinationUnitNumber.0 i $rlCopyDestinationUnitNumber \
rlCopyDestinationFileName.0 s $rlCopyDestinationFileName
}
backup
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide