{"id":128,"date":"2014-08-24T12:19:19","date_gmt":"2014-08-24T19:19:19","guid":{"rendered":"https:\/\/www.rackbuzz.com\/?p=128"},"modified":"2014-08-24T12:21:09","modified_gmt":"2014-08-24T19:21:09","slug":"cisco-config-backup-redux-snmp-this-time","status":"publish","type":"post","link":"https:\/\/www.rackbuzz.com\/?p=128","title":{"rendered":"Cisco Config Backup Redux &#8211; SNMP This Time"},"content":{"rendered":"<p>We recently installed new routers and voice gateways, and I was torn between enabling telnet or figuring out a better way to perform my config backups. I&#8217;m still a big believer in security and free solutions, so I went on the hunt and dug into using SNMP. As it turns out, the hardest part about using SNMP to back up a Cisco config is getting the MIBs installed on your particular distro. Using Debian this time, I had a pretty simple go of it. Once you get net-snmp figured and get your MIBs installed into the right path, you just have to add CISCO-CONFIG-COPY-MIB to your snmp.conf and you&#8217;re ready to roll.<\/p>\n<p>&nbsp;<\/p>\n<p>Here&#8217;s the bash script I wrote to automate a config backup of my entire organization. The only prerequisite to the script is a simple text file of all of your hosts. Maintaining the text file is the only hard part.<\/p>\n<p>[bash]<br \/>\n#!\/bin\/bash<br \/>\nbudir=\/tftpboot\/cfg-`date +%Y-%m-%d-%H%M`       #Backup directory<br \/>\nsnmpcom=private                                 #SNMP Community goes here (Must be RW)<br \/>\ns=10.1.1.10                                     #IP of your TFTPD<br \/>\nrslist=\/root\/bin\/backup\/rslist                  #Path to Router\/Switch list, one per line<br \/>\nr=$(($RANDOM%1000))                             #Random number to be used for snmpset<br \/>\n#################################################<br \/>\nmkdir $budir                                    #Create backup directory<br \/>\nfor a in `cat $rslist`<br \/>\ndo<br \/>\n        touch $budir\/$a                         #These two lines are only required if your<br \/>\n        chmod 777 $budir\/$a                     #tftpd doesn&#8217;t support the -c (create) option<\/p>\n<p>        #This line is the actual snmpset command to set all of the variables.<br \/>\n        snmpset -v2c -c $snmpcom $a ccCopyProtocol.$r i tftp \\<br \/>\n                ccCopySourceFileType.$r i runningConfig \\<br \/>\n                ccCopyDestFileType.$r i networkFile \\<br \/>\n                ccCopyServerAddress.$r a $s \\<br \/>\n                ccCopyFileName.$r s $budir\/$a<\/p>\n<p>        #This line is the one that actually triggers the backup.<br \/>\n        snmpset -v2c -c $snmpcom $a ccCopyEntryRowStatus.$r i active<br \/>\ndone<br \/>\n[\/bash]<\/p>\n<p>&nbsp;<\/p>\n<p>Save this script and create a cron job and you&#8217;re all set.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We recently installed new routers and voice gateways, and I was torn between enabling telnet or figuring out a better way to perform my config backups. I&#8217;m still a big believer in security and free solutions, so I went on the hunt and dug into using SNMP. As it turns out, the hardest part about [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-128","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.rackbuzz.com\/index.php?rest_route=\/wp\/v2\/posts\/128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rackbuzz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rackbuzz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rackbuzz.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rackbuzz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=128"}],"version-history":[{"count":11,"href":"https:\/\/www.rackbuzz.com\/index.php?rest_route=\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/www.rackbuzz.com\/index.php?rest_route=\/wp\/v2\/posts\/128\/revisions\/139"}],"wp:attachment":[{"href":"https:\/\/www.rackbuzz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rackbuzz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rackbuzz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}