cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

136
Views
0
Helpful
3
Replies
Highlighted
Beginner

Weekly backup with EEM

Dear,

 

I would like to know if it is possible to create a weekly backup of configuration with Cisco Router.

 

I tried with this configuration but the result is "abort":

 

event manager applet "name_of_event"
event timer watchdog time 604800 (about 7 days)
action 1.0 cli command "enable"
action 2.0 cli command "copy running-config ftp:"
action 3.0 cli command "server_ip_address"
action 4.0 cli command "folder/name_of_bck_configuration_file"
action 5.0 cli command "exit"

 

Result of command "show event manager statistics policy":


No. Class Triggered Suppressed Run Time Run Time Name
-------------------------------------------------------------------------------
1 applet 1 0 20.042 20.042 "name_of_event"
event {} timer watchdog (Time Remaining: 514224.208)

 

Result of command "show event manager history events detailed":

No. Job Id Proc Status Time of Event Event Type Name
1 1 Actv abort Tue Jul28 16:39:16 2020 timer watchdog applet: "name_of_event"
timer_time 3804939556.681 timer_remain 604800.000

 

Result of command "show event manager version":
Embedded Event Manager Version 4.00


How can i solve it?

 

Regards

3 REPLIES 3
Highlighted
Cisco Employee

Re: Weekly backup with EEM

Hello TNMVA,

 

For troubleshooting / testing EEM scripts, I recommend a couple things:

  • Setting the event to "none" lets you manually trigger the script at will from privileged exec. To manually trigger the script use the  following command:
    event manager run <script_name>
  • You can use a debug to see what CLI parser is reporting, including any error messages. To debug the CLI commands, use the following command:
    debug event manager action cli

 

I took a look at your script and I believe I may know what is failing, but I don't have EEM debugs from your script to confirm. When you copy a file via FTP, you need to include the username and password in the CLI command (unless it's specified in global config via "ip ftp username / password"). The CLI parser may have been waiting for an input and script timed out after 20 seconds. I added a pattern keyword to your script, which essentially tells the script to look for a string in response to the command that was just entered (reference). If the string is a match, then proceed to next script line and enter the command in response to the pattern. The pattern keyword would be used for things like copy command or reload command where additional questions are asked prior to executing the command.

 

Please see below script and let me know if it works. If it does not work, please let me know the results of debugging.

event manager applet "name_of_event"
event timer watchdog time 604800
action 1.0 cli command "enable"
action 2.0 cli command "copy running-config ftp://<username>:<password>@<server_IP>" pattern "Address or name of remote host"
action 3.0 cli command "<server_IP>" pattern "Destination filename"
action 4.0 cli command "<file_path>"
action 5.0 cli command "exit"

 

Highlighted
Beginner

Re: Weekly backup with EEM

Hi,

 

thank you for the support.

 

I applied your suggestions:

 

event manager applet "script_name"
event timer watchdog time 604800
action 1.0 cli command "enable"
action 2.0 cli command "copy running-config ftp://name:password@Server_IP" pattern "IP_address"
action 3.0 cli command "IP_address" pattern "path_name/file_name"
action 4.0 cli command "path_name/file_name"
action 5.0 cli command "exit"
action 6.0 syslog priority informational msg "Configuration successfully written to FTP server"

 

and it worked properly.

 

Regards.

 

Highlighted
VIP Mentor

Re: Weekly backup with EEM

Hello,

 

an alternative would be the script below, which also gives your backed up file an epoch style timestamp:

 

event manager applet BACKUP_CONFIG
description Backup-Running-Config-To-TFTP
event timer watchdog time 604800
action 0.1 info type routername
action 1.0 cli command "enable"
action 1.1 cli command "copy run tftp" pattern "Address"
action 1.2 cli command "192.168.1.2" pattern "filename"
action 1.3 cli command "$_info_routername-config_$_event_pub_sec"
action 2.0 syslog priority informational msg "Configuration successfully written to TFTP server"!

Content for Community-Ad