Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Archiving Router Configuration to TFTP Server Automatically

Does anyone have a config that they can share on backing up the running config on RouterA daily at 11pm to a TFTP server? I think it involves the "archive" command.

TFTP Address: 10.8.4.201

Path location and File Name: TFTPBoot\RouterA.txt

Time: Daily at 11pm

Thanks in advance.

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Archiving Router Configuration to TFTP Server Automatically

With kron you can NOT go to config mode.

It's only for EXEC mode, so it wont let you go to config terminal in KRON:

http://www.cisco.com/en/US/docs/ios/netmgmt/command/reference/nm_08.html#wp1058933

You should use EEM to achieve this.

event manager applet SaveConfigToTFTP

event cli pattern "write" sync no skip no

action 1 cli command "enable"

action 2 cli command "configure terminal"

action 3 cli command "file prompt quiet"

action 4 cli command "end"

action 5 cli command "copy running-config tftp://tftp-server/router-confg"

action 6 cli command "configure terminal"

action 7 cli command "no file prompt quiet"

action 8 cli command "end"

(write memory|copy running-config startup-config)"

To set a timer, your applet could configure another, timer applet to run. For example:

action 010 cli command "event manager applet mytimer"

action 011 cli command "event timer countdown time 30"

action 012 cli command "action ..."

Cisco Employee

Re: Archiving Router Configuration to TFTP Server Automatically

Yes, you can use the built-in IOS config archive feature to do this. Your config can be as simple as say:

archive

path tftp://10.1.1.1/configs/$h-$t

maximum 14

time-period 60

write-memory

With this config, the device will write a new file to TFTP with the name HOSTNAME-DATE-X where HOSTNAME is the hostname of the device, DATE is the current date/time, and X is a number from 0 to 14. Config archives will be taken periodically every hour, or whenever a write mem is executed.

Note: most TFTP servers won't like this kind of thing. They require that a file exist before it can be written to. You may want to consider a more secure protocol such as SCP.

There is also a really good Embedded Event Manager policy at http://forums.cisco.com/eforum/servlet/EEM?page=eem&fn=script&scriptId=1103 which will archive the config only when it has changed. It works in conjunction with the above Config Archive feature plus the SYS-5-CONFIG_I syslog message.

4 REPLIES

Re: Archiving Router Configuration to TFTP Server Automatically

I think you'd need to use a kron job to actualy specify a specific time. Else you could do it every so many minutes. Like this...

config t

archive

path tftp:\\backupserver\configs

time-period 180

Re: Archiving Router Configuration to TFTP Server Automatically

With kron you can NOT go to config mode.

It's only for EXEC mode, so it wont let you go to config terminal in KRON:

http://www.cisco.com/en/US/docs/ios/netmgmt/command/reference/nm_08.html#wp1058933

You should use EEM to achieve this.

event manager applet SaveConfigToTFTP

event cli pattern "write" sync no skip no

action 1 cli command "enable"

action 2 cli command "configure terminal"

action 3 cli command "file prompt quiet"

action 4 cli command "end"

action 5 cli command "copy running-config tftp://tftp-server/router-confg"

action 6 cli command "configure terminal"

action 7 cli command "no file prompt quiet"

action 8 cli command "end"

(write memory|copy running-config startup-config)"

To set a timer, your applet could configure another, timer applet to run. For example:

action 010 cli command "event manager applet mytimer"

action 011 cli command "event timer countdown time 30"

action 012 cli command "action ..."

New Member

Re: Archiving Router Configuration to TFTP Server Automatically

The archive command works well with L3 Cisco devices. In switches, the archivve command is not available in global config mode. Is there a replacement command?

Cisco Employee

Re: Archiving Router Configuration to TFTP Server Automatically

Yes, you can use the built-in IOS config archive feature to do this. Your config can be as simple as say:

archive

path tftp://10.1.1.1/configs/$h-$t

maximum 14

time-period 60

write-memory

With this config, the device will write a new file to TFTP with the name HOSTNAME-DATE-X where HOSTNAME is the hostname of the device, DATE is the current date/time, and X is a number from 0 to 14. Config archives will be taken periodically every hour, or whenever a write mem is executed.

Note: most TFTP servers won't like this kind of thing. They require that a file exist before it can be written to. You may want to consider a more secure protocol such as SCP.

There is also a really good Embedded Event Manager policy at http://forums.cisco.com/eforum/servlet/EEM?page=eem&fn=script&scriptId=1103 which will archive the config only when it has changed. It works in conjunction with the above Config Archive feature plus the SYS-5-CONFIG_I syslog message.

2199
Views
5
Helpful
4
Replies