cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
26809
Views
20
Helpful
19
Replies

Automatic Backup Using EEM

Cisco-Spider
Level 1
Level 1

Dear All,

I want to use EEM for automatic backup of all my routers and switches on a TFTP server.

Please any 1 can help me ?

Regards,

Kaven

1 Accepted Solution

Accepted Solutions

Something like this would work.

event manager applet backup-config

event timer watchdog time 86400

action 1.0 cli command "enable"

action 2.0 info type routername

action 3.0 cli command "copy runn tftp://x.x.x.x/$_info_routername.cfg" pattern "Address"

action 4.0 cli command "" pattern "Destination"

action 5.0 cli command ""

This will work with any device running EEM 2.3 or higher.  Note: a file names HOSTNAME.cfg needs to exist on the TFTP server prior to the copy.  HOSTNAME is the hostname of the device.

View solution in original post

19 Replies 19

Joe Clarke
Cisco Employee
Cisco Employee

How do you want this backup to be triggered?  Have you looked at the built-in IOS config archive feature instead?

http://www.cisco.com/en/US/docs/ios/fundamentals/configuration/guide/cf_config-rollback.html

Dear Joseph,

Thank you for your reply. I have done it with config archive feature before but now i want to do it with EEM. I want to make a backup after every 24 hours.

Something like this would work.

event manager applet backup-config

event timer watchdog time 86400

action 1.0 cli command "enable"

action 2.0 info type routername

action 3.0 cli command "copy runn tftp://x.x.x.x/$_info_routername.cfg" pattern "Address"

action 4.0 cli command "" pattern "Destination"

action 5.0 cli command ""

This will work with any device running EEM 2.3 or higher.  Note: a file names HOSTNAME.cfg needs to exist on the TFTP server prior to the copy.  HOSTNAME is the hostname of the device.

Thank you very much for your reply, yup its working.

Now one more thing, if i want to track any changing in a Running-Configuration, how can i do it? any idea ?

Thanks once again for your support.

You can enable logging as part of the config archive feature.  Then, any config command that is entered is sent via syslog.

archive

log config

logging enable

logging persistent auto

notify syslog contenttype plaintext

Thank you very much.

Now i am trying one more scenario.

  • EEM applet needs to write the date and time to a file saved in flash (flash://config-log.txt)
  • EEM applet need to activate every time someone make changes to the running config
  • Syslog message has to be generated with the string “configuration has been changed”

On Router

Event manger applet WriteMem

event cli pattern “write mem.*” sync yes

action 10 cli command “enable”

action 20 cli command “show clock | append flash:config-log.txt” pattern “confirm”

action 30 cli command “y”

action 40 syslog msg “configuration has been change"

This solution is not working, please advice.

Why not?  What errors are you getting?  The applet looks correct.  It is working for me on my 2821.

Hi mate,

I followed the discussion and I am interested if it is possible to get the date.

show clock returns

17:59:00.741 EET Thu Nov 29 2012

Can I extract only the month, day and year? I want to create on the TFTP server a folder using this format: month, day and year.

Many thanks!

Depends on the version of code.  If you hvae EEM 3.0 or higher, you can do:

action X cli "show clock"

action X+1 regexp "([0-9]+) ([0-9]+)" $_cli_result match day year

action X+2 regexp "([a-zA-Z]+) [0-9]+ [0-9]+" $_cli_result match month

action X+3 puts "Month: $month, Day: $day, Year: $year"

Although I thought I know something about regex, I don't understand how do you extract the month from the output, basically you extract the first text from the $cli_result but why this string: a-zA-Z ?

Anyway I wanted to use this to create periodic router backups and send each file to a specific folder using the date; here is what I collected from this forum (basically your work):

event manager applet bc

event none

action 1.0 cli command "enable"

action 2.0 info type routername

action 3.0 cli command "show clock"

action 4.0 regexp "([0-9]+) ([0-9]+)" "$_cli_result" match day year

action 5.0 regexp "([a-zA-Z]+) [0-9]+ [0-9]+" "$_cli_result" match month

action 6.0 set folder "$day-$month-$year"

action 7.0 cli command "copy runn tftp://x.x.x.x/$folder/$_info_routername.cfg" pattern "Address"

action 8.0 cli command "" pattern "Destination"

action 9.0 cli command ""

I am using Solarwinds TFTP Server on Windows and basically it turns off our efforts as it doesn't allow me to add a new folder from client's perspective; I will try with a TFTP server running on Linux and see if possible.

Bottom line: I am very pleased about the result and I thank you again for your answers and patience!

The pattern a-zA-Z matches all letters regardless of case.

As for the use case, you could use the built-in IOS config archive feature to do what you want.  See

http://www.cisco.com/en/US/docs/ios/12_3t/12_3t7/feature/guide/gtrollbk.html for more details.

I already have deployed archive feature on all equipments, it's just I want to automatically move backup files to a folder named by the date it is done.

I tried with Linux TFTP but hit the same issue: cannot create a folder on TFTP server, it has to be manually defined before.

So I believe I will create a folder for each equipment and append date to the running-config.

archive is set this way:

archive

log config

  logging enable

path tftp://A.B.C.D/Router_2811

write-memory

time-period 21600

Do you know if it is possible each time the scheduled backup run, to append date to the config-file?

You can use $h and $t to stand for hostname and date/time respectively.

hi Joseph, 

I am totally new to EMM. How would you add a date in after the file name to be sent to the tftp server ?

action 3.0 cli command "copy runn tftp://x.x.x.x/$_info_routername.cfg_YYMMDD" pattern "Address"

Also what does the pattern "Address" achieve ?

Review Cisco Networking for a $25 gift card