Ad Widget

Collapse

Cisco device automated, quick manual configuration backup:

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nelg
    Junior Member
    • Jun 2020
    • 6

    #1

    Cisco device automated, quick manual configuration backup:

    ****I DID IT!!!! Just verified and this is working properly!! (quick backup from selecting on a map, I'll let you know when I get the automated backup script setup****

    Zabbix script to allow selecting a map icon and clicking backup for Cisco devices

    Click image for larger version  Name:	backup-img1.PNG Views:	0 Size:	22.4 KB ID:	403403
    Click image for larger version  Name:	backup-img2.PNG Views:	0 Size:	31.9 KB ID:	403404

    Click image for larger version  Name:	backup-img3.PNG Views:	0 Size:	29.8 KB ID:	403405

    Step 1: First create this script in /usr/lib/zabbix/externalscripts

    Code:
    nano /usr/lib/zabbix/externalscripts/CiscoDeviceBackup.sh
    Copy/paste this into nano ****add your TFTP server IP into line 9**** - for FTP. SCP, etc, see the reference at the bottom of this post to re-configure the script.

    Code:
    #!/bin/bash
    # Cisco Device Running Config Backup Script - Created by nelg
    # references used to create this script: [URL="https://www.ciscozine.com/how-to-save-configurations-using-snmp/"]https://www.ciscozine.com/how-to-sav...ns-using-snmp/[/URL] - [URL]http://linuxcommand.org/lc3_wss0040.php[/URL] - [URL="https://www.lifewire.com/pass-arguments-to-bash-script-2200571"]https://www.lifewire.com/pass-argume...script-2200571[/URL] - [URL="https://stackoverflow.com/questions/1194882/how-to-generate-random-number-in-bash/1195035"]https://stackoverflow.com/questions/...n-bash/1195035[/URL]
    randomNumber=$((100 + RANDOM % 999))
    backupDate=$(date +%Y%m%d%H%M%S)
    snmpset -c $1 -v 2c $2 10.1 1.3.6.1.4.1.9.9.96.1.1.1.1.2.$randomNumber i 1
    snmpset -c $1 -v 2c $2 1.3.6.1.4.1.9.9.96.1.1.1.1.3.$randomNumber i 4
    snmpset -c $1 -v 2c $2 1.3.6.1.4.1.9.9.96.1.1.1.1.4.$randomNumber i 1
    snmpset -c $1 -v 2c $2 1.3.6.1.4.1.9.9.96.1.1.1.1.5.$randomNumber a [U][B][Your TFTP server IP goes here][/B][/U]
    snmpset -c $1 -v 2c $2 1.3.6.1.4.1.9.9.96.1.1.1.1.6.$randomNumber s $3.Backup.$backupDate.Backup
    snmpset -c $1 -v 2c $2 1.3.6.1.4.1.9.9.96.1.1.1.1.14.$randomNumber i 1
    echo $1 $2 $3.Backup.$backupDate.Backup Successfully Created
    Save the file (in Nano it's CTRL+O, save the file, and then CTRL+X to quit

    Step 2: Execute the following to make the bash script executable
    Code:
    chmod 755 /usr/lib/zabbix/externalscripts/CiscoDeviceBackup.sh
    Step 3: Create the following user script in Zabbix frontend:

    Name: Cisco Running Config Backup
    Type: Script
    Execute on: Zabbix Server (could be other, just the way I did it)
    Everything else leave at defaults

    Commands box, copy and paste this:
    Code:
    ./usr/lib/zabbix/externalscripts/CiscoDeviceBackup.sh {$SNMP_COMMUNITY} {HOST.IP} {HOSTNAME}
    Step 4: Test by going to the map, clicking on a Cisco device, and selecting Cisco Running Config Backup.

    There will be an error shown (just one) but it should still work.

    Then go check your TFTP server to ensure it copied correctly.

    *******************************************Prelimi nary information*************************************** ****
    Need some help, almost there! So I have been wanting a way to do automated backups and the HUGE nicety of having a script on maps to just click on a cisco device and click backup to backup the running or start config on the fly.

    I found these snmpset commands online. I have tested this setup with a Cisco 3850 (non production) from the Zabbix server console and it worked perfectly! Now just need to set up the script in Zabbix to run this from the frontend:

    The requirements are for the SNMP string to be setup on the switch, and the string requires having write access to function properly.

    Example:
    snmpset -c SNMPSTRING123 -v 2c 10.10.10.1 10.1 1.3.6.1.4.1.9.9.96.1.1.1.1.2.123 i 1

    snmpset -c SNMPSTRING123 -v 2c 10.10.10.1 1.3.6.1.4.1.9.9.96.1.1.1.1.3.123 i 4
    snmpset -c SNMPSTRING123 -v 2c 10.10.10.1 1.3.6.1.4.1.9.9.96.1.1.1.1.4.123 i 1
    snmpset -c SNMPSTRING123 -v 2c 10.10.10.1 1.3.6.1.4.1.9.9.96.1.1.1.1.5.123 a 10.10.10.254
    snmpset -c SNMPSTRING123 -v 2c 10.10.10.1 1.3.6.1.4.1.9.9.96.1.1.1.1.6.123 s testRunningconfig.backup
    snmpset -c SNMPSTRING123 -v 2c 10.10.10.1 1.3.6.1.4.1.9.9.96.1.1.1.1.14.123 i 1

    Definition:

    snmpset -c [SNMP String] -v 2c [IP Address of CiscoDevice] 10.1 1.3.6.1.4.1.9.9.96.1.1.1.1.2.[randomNumber *] i [Protocol - 1=tftp, 2=ftp, 3=rcp, 4=scp, 5=sftp]
    snmpset -c [SNMP String] -v 2c [IP Address of CiscoDevice] 1.3.6.1.4.1.9.9.96.1.1.1.1.3.[randomNumber *] i [Sourcefile to copy from - 1=networkFile, 2=iosFile, 3=startupConfig, 4=runningConfig, 5=terminal, 6=fabricStartupConfig]
    snmpset -c [SNMP String] -v 2c [IP Address of CiscoDevice] 1.3.6.1.4.1.9.9.96.1.1.1.1.4.[randomNumber *] i [Dest.file to copy to - 1=networkFile, 2=iosFile, 3=startupConfig, 4=runningConfig, 5=terminal, 6=fabricStartupConfig]
    snmpset -c [SNMP String] -v 2c [IP Address of CiscoDevice] 1.3.6.1.4.1.9.9.96.1.1.1.1.5.[randomNumber *] a [IP of Server to connect to]
    snmpset -c [SNMP String] -v 2c [IP Address of CiscoDevice] 1.3.6.1.4.1.9.9.96.1.1.1.1.6.[randomNumber *] s [dest or source filename]
    snmpset -c [SNMP String] -v 2c [IP Address of CiscoDevice] 1.3.6.1.4.1.9.9.96.1.1.1.1.14.[randomNumber *] i [The status of the table/file entry - 1=active, 2=notInService, 3=notReady, 4=createAndGo, 5=createAndWait, 6=destroy]

    *Each time you copy to or from a device using SNMP, choose a random number. This number creates a row instance. It must be the same everywhere in your command. Once you use a specific number, it can not be used again before it times out. The timeout is five minutes. If you use the same number within the five minutes, you get an error (SNMP: Inconsistent value.)

    Source: https://www.ciscozine.com/how-to-sav...ns-using-snmp/

    Unfortunately I'm not a scripting guru. Could use some help from my friends out there and I believe this would greatly help any network admins using Zabbix I'll update the post as I build the script or someone else posts solutions.

    What I am thinking is on execution of the script, create a random number to use in the random number field, sourcefile, dest File, IP of server to connect to, and status of the table entry would be static, and lastly the file name would be {HOSTNAME}.ConfigBackup.{Date}{Time}.backup (not sure if anything else besides HOSTNAME is correct)
    Last edited by nelg; 17-06-2020, 00:16.
  • DrezaoAraujo
    Junior Member
    • Sep 2019
    • 4

    #2
    Hello Nelg!

    This is great!

    Can you help me configure it to Backup HP Procurve Switches?

    I cannot get that to work

    Comment

    • Hamardaban
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • May 2019
      • 2713

      #3
      Not all models and firmwares have the ability to accept snmp commands, and even if there is an snmp management - there are not necessarily commands for performing backup by sftp.
      Please refer to the documentation for your devices to clarify these features

      Comment

      • Heaton285
        Junior Member
        • Feb 2021
        • 1

        #4
        Configuration backup is an increasingly important foundation for successful operation of your Cisco switches. It is essential to back up configurations to overcome network downtimes and to resume normal functioning. Failing to follow authentic configuration backup methods while backing up Cisco switch configurations can put your network devices in hot soup.

        Nox
        Last edited by Heaton285; 09-02-2021, 06:26.

        Comment

        Working...