01-23-2017 03:35 AM
Hi
So the following script works well on the Catalyst, it backs up the config via TFTP as soon as somebody enters and exits conf t mode.
event manager session cli Username
event manager applet Backup-Running-Config-To-TFTP
description Backup-Running-Config-To-TFTP
event syslog pattern "%SYS-5-CONFIG_I: Configured from"
action 0 info type routername
action 1.0 cli command "enable"
action 1.1 cli command "copy run tftp" pattern "Address"
action 1.2 cli command "x.x.x.x" pattern "filename"
action 1.3 cli command "$_info_routername-config_$_event_pub_sec"
action 2.0 syslog priority informational msg "Configuration change detected. Write to TFTP succesfully executed!"
However it doesn't seem to work so well on the Nexus 5k.
The session cli command is not accepted and I just get hundreds of the following in the log:
2017 Jan 22 20:19:33 HOSTNAME %VSHD-5-VSHD_SYSLOG_CONFIG_I: Configured from vty by LOCALADMIN on vsh.8681
As soon as I do conf t and exit it, the above message appears in the log multiple times a second and seems to loop.
Any ideaS?
Thanks
Solved! Go to Solution.
01-23-2017 07:59 AM
This applet won't work on NX-OS. First, the syslog message for config change is different. Second, unless you are on 7.3 code, the syntax for the applet is very different on NX-OS. Third, even on the latest code, the "info" action is not supported on NX-OS. Finally, I haven't tried to use variables like _event_pub_sec. I am not certain they work on NX-OS. For NX-OS (and I've only done this on the 7K), Python is a better alternative.
01-23-2017 07:59 AM
This applet won't work on NX-OS. First, the syslog message for config change is different. Second, unless you are on 7.3 code, the syntax for the applet is very different on NX-OS. Third, even on the latest code, the "info" action is not supported on NX-OS. Finally, I haven't tried to use variables like _event_pub_sec. I am not certain they work on NX-OS. For NX-OS (and I've only done this on the 7K), Python is a better alternative.
01-24-2017 01:25 AM
That is disappointing, we were hoping to find a single solution to backup our switches but it seems the Catalyst and Nexus are fairly different in a lot of aspects.
Starting to wonder if the 68xx would have been a better option than the Nexus.
03-02-2017 04:18 PM
REMOVED.
I didn't realize that you've already tried the "archive" command.
04-10-2017 04:09 AM
You could use this it works on my nexus devices 5s and 7s , you could tweak it to send it to storage , we just have it backing up to flash locally as Prime already takes copies to an NFS location remotely , found the snmp oid online it works well takes it every 12 hours sends it to flash
event manager applet NX-OS_Configuration_Backup
event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.6.1 get-type exact entry-op le entry-val 12345 poll-interval 43200
action 1.0 cli command enable
action 2.0 cli copy run bootflash:NX-OS_Latest_Running_Config_Backup
action 3.0 syslog priority notifications msg Running_Config_Backup_Complete
*************************
37 04/09/2017 00:06:54 snmp active(1) NX-OS_Configuration_Backup
38 04/09/2017 12:06:56 snmp active(1) NX-OS_Configuration_Backup
39 04/10/2017 00:06:58 snmp active(1) NX-OS_Configuration_Backup
04-11-2017 12:12 AM
I managed to get this working after hitting this bug:
https://bst.cloudapps.cisco.com/bugsearch/bug/CSCvc16748/?referring_site=bugquickviewredir
The NXOS didn't like the quotes for some reason.
Here is my config:
echo "copy config.txt tftp://192.168.55.2/$(SWITCHNAME)_Running-Config_$(TIMESTAMP).txt vrf default" >> filename
event manager applet Schedule_Backup
event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.6.1 get-type exact entry-op le entry-val 12345 poll-interval 60
action 1.0 cli run-script bootflash:filename
action 2.0 syslog priority notifications msg Auto-Backup-Complete
The workaround to the quotes error was to do the same command inside a file which is stored in the bootflash and then call this file as part of the EEM script.
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