EEM Auto Backup Script on Nexus?

Answered Question
Jan 23rd, 2017
User Badges:
  • Gold, 750 points or more
  • Community Spotlight Award,

    Small Business, November 2015

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

Correct Answer by Joe Clarke about 3 months 1 day ago

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
Correct Answer
Joe Clarke Mon, 01/23/2017 - 07:59
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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.

devils_advocate Tue, 01/24/2017 - 01:25
User Badges:
  • Gold, 750 points or more
  • Community Spotlight Award,

    Small Business, November 2015

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.

Leo Laohoo Thu, 03/02/2017 - 16:18
User Badges:
  • Super Gold, 25000 points or more
  • Hall of Fame,

    The Hall of Fame designation is a lifetime achievement award based on significant overall achievements in the community. 

  • Cisco Designated VIP,

    2017 LAN, Wireless

REMOVED.

I didn't realize that you've already tried the "archive" command.

Mark Malone Mon, 04/10/2017 - 04:09
User Badges:
  • Purple, 4500 points or more
  • Cisco Designated VIP,

    2017 LAN

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

devils_advocate Tue, 04/11/2017 - 00:12
User Badges:
  • Gold, 750 points or more
  • Community Spotlight Award,

    Small Business, November 2015

I managed to get this working after hitting this bug:

https://bst.cloudapps.cisco.com/bugsearch/bug/CSCvc16748/?referring_site...

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.


Actions

This Discussion