cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2756
Views
20
Helpful
9
Replies

EEM Script for Config Backup 5K

pat.mchenry
Level 1
Level 1

Hi,

 

I'm trying to automate backup configurations from our 5Ks. I understand the archive command is not supported on the 5K and we've used that successfully on our IOS gear.

 

Below is my EEM script...can anyone see an issue with it?

 

Curiously, the command below does work:

 

copy running-config scp://netconfiguser:password@ip_address/folder-Configs/filename- vrf VRF_INTERNAL

 

The config is sent to our server and placed in the folder

 

The EEM script is not working. It goes to the server...I can see a notification pop up on my windows server, but I believe it could be having an auth issue created by the order of operations.

 

NEX01(config)# event manager applet CONFIG-BACKUP-TO-SCP-SERVER
NEX01(config-applet)# description "Copy running-config to SCP server"
NEX01(config-applet)# event cli match "copy running-config startup-config"
NEX01(config-applet)# action 1.0 cli copy running-config startup-config
NEX01(config-applet)# action 2.0 cli copy running-config scp://netconfiguser:password@ip_address/folder-Configs/filename- vrf VRF_INTERNAL

 

Thank you, Pat

 

 

 

9 Replies 9

Mark Malone
VIP Alumni
VIP Alumni
Hi
i used this to drop them into flash for local backup once a day as i had prime pulling the config to remote server , that specific oid was for the 5k , you could try tweak this for scp see if it works as an option

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 "command enable"
action 2.0 cli command "copy run bootflash:NX-OS_Latest_Running_Config_Backup"
action 3.0 syslog priority notifications msg " Running_Config_Backup_Complete"


dir bootflash:NX?
bootflash:NX-OS_Latest_Running_Config_Backup

Thanks, Mark.

 

 

My script appears to be sending the copy scp command to the server, but I believe the server is asking for a password and my script is not sending it....so it hangs. When I run the copy running-config scp command manually I get a password prompt.

copy running-config scp://user:password@172.X.X.X/folder-Configs/file- vrf EXAMPLEVRF

user@172.X.X.X's password:

 

I enter the password and the configuration is sent to my server and saved in the folder.

 

If I could send a password through the script, then I think it would work.

 

I tried the below, but it did not work.

 

event manager applet CONFIG-BACKUP-TO-SCP-SERVER

event cli match "copy running-config startup-config"

action 1.0 cli copy running-config scp://user:password@172.X.X.X/folder-Configs/file- vrf EXAMPLEVRF

action 2.0 password

 

Also, tried 

 

event manager applet CONFIG-BACKUP-TO-SCP-SERVER

event cli match "copy running-config startup-config"

action 1.0 cli copy running-config scp://user:password@172.X.X.X/folder-Configs/file- vrf EXAMPLEVRF

action 1.1 password

 

Thank you, Pat

 

igoris.seimys
Level 1
Level 1

try:

action 1.0 cli "copy running-config scp://user:password@172.X.X.X/folder-Configs/file- vrf EXAMPLEVRF" pattern "password"

Hello

Below are the scripts ive used in the past.

N7-9kscli alias name NetcmBackup copy startup-config tftp://x.x.x.x/$(SWITCHNAME)__$(TIMESTAMP).cfg vrf default

config terminal
scheduler job name switchbackup_to_Netcm
NetcmBackup

end

config terminal
scheduler schedule name NETCM_Backup
time daily 23:59
job name switchbackup_to_Netcm
end

 

N5Ks
cli alias name NetcmBackup copy startup-config tftp://x.x.x.x/$(SWITCHNAME)__$(TIMESTAMP).cfg vrf default

event manager applet Netcm_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 86400
action 1.1 cli command "enable"
action 1.2 cli command "NetcmBackup"
action 1.3 syslog priority notifications msg "Running_config_backup_to_Netcm_Complete"
action 1.4 cli command "end"

 


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

igoris.seimys
Level 1
Level 1

is there a working script for scp on N5K? It does not work for me.

Probably because there are two prompts, for unknown server ssh key first time and for scp password. I used pattern "password" but it fails. Also not sure how to run proper debug to see what is going on.

'Show event manager events action ' does not give much info.

Igoris,

 

What I did in the end was create an alias for "wr" 

 

cli alias name wr copy running-config scp://user:password@X.X.X.X/NEXUS-SWITCH-Configs/NEXUS-SWITCH-Config-$(TIMESTAMP) vrf VRF_EXAMPLE

 

This is not a scheduled task, but the next best thing. So every time I issue "wr" it goes right to my SFTP server and into a folder I've created just for the Nexus with timestamp.

 

HTH, Pat

 

Hello Pat

Glad you have managed to get it to work,

For the 5K's in my example above I've just gave the alias a different name but just confirm the last time i checked my backups for the 5ks were initiating every 24 hrs


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

nice idea, but it prompts me for password, in spite of it is specified in the line.

And other thing- I need to instruct all engineers to use alias wr.

 

Yea - actually forgot about the prompting for password...sort of a pain in the butt.

 

Agreed, not a perfect solution, but I needed to move on as I couldn't get it to work totally automated within a reasonable amount of time. Since I only have 2 Nexuses it's not a big deal for me. The important thing is I'm saving my configs.

 

Thx

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco