cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4911
Views
5
Helpful
3
Replies

TCL script - Backup config

oemoralesjr
Level 1
Level 1

I am wanting to write a tcl scrip for the following scenario.  I have two routers at a remote branch that are directly connected and running HSRP.  I would like to have a TCL script that copies the running config over to the other routers flash every so often as a backup.  Anyone done anything like this.  I have basic knowledge of TCL and am tryin to save myself some time and headache.  I guess I'm hoping someone already has a script written for a scenario like this.

3 Replies 3

Joe Clarke
Cisco Employee
Cisco Employee

I don't know of anyone that has done this kind of thing before.  There are quite a few details missing as well.  For example, will this be a bidirectional sync, or will one switch always coopy its config to the other?  I am guessing you will just be using the backup switch as file storage rather than trying to load the primary switch's config on the backup switch.

The easiest solution in my mind is to use the RCP, SCP, or TFTP server on the backup switch, then just copy the config from the primary to the backup.  In that case, a simple EEM applet could do what you want.  For example, to copy the config every day using SCP, you can use the following:

event manager applet sync-config

event timer watchdog time 86400

action 1.0 cli command "enable"

action 2.0 cli command "copy running scp://user:pass@10.1.1.1/backup-config" pattern "Address"

action 3.0 cli command "10.1.1.1" pattern "username"

action 4.0 cli command "user" pattern "filename"

action 5.0 cli command "backup-config"

Here, replace user with your username and pass with your password.

action 2.0 cli command "copy running scp://user:pass@10.1.1.1/backup-config" pattern "Address"

 

for above command i have embedded user with username and pass with password of my username  but still it prompts me for password?

 

Kindly let me know why

yeah that's unfortunate but what I had to deal with it also.  Add the following lines and you should be good.

action 1.1 info type routername

action 5.0 cli command "backup-config" pattern  "Password:"

action 6.0 cli command "password"

 

To help you troubleshoot the script run the copy running scp://user:pass@10.1.1.1/backup-config from your cli, pay attention to the prompts device responds with the are the "Patterns" that the script is waiting for, the following cli commands are your responses.

If you are feeling creative try adding

action 1.1 info type routername to capture the routers name

edit action 5.0 to cli command "$_info_routername-config" pattern "Password:"

to append the router's name to the file name on the remote system.

and add action 6.1 syslog priority informational msg "Config sync was executed"

to ass a message in your syslog