12-27-2011 01:24 AM
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
Solved! Go to Solution.
12-28-2011 08:19 AM
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.
12-27-2011 06:02 PM
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
12-27-2011 11:05 PM
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.
12-28-2011 08:19 AM
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.
12-29-2011 12:08 AM
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.
12-29-2011 07:49 AM
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
01-04-2012 03:54 AM
Thank you very much.
Now i am trying one more scenario.
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.
01-07-2012 10:21 PM
Why not? What errors are you getting? The applet looks correct. It is working for me on my 2821.
11-29-2012 08:02 AM
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!
12-02-2012 06:09 PM
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"
12-03-2012 01:40 AM
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!
12-04-2012 12:42 PM
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.
12-04-2012 11:07 PM
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?
12-05-2012 08:18 AM
You can use $h and $t to stand for hostname and date/time respectively.
02-16-2015 08:58 AM
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 ?
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