cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
19838
Views
15
Helpful
5
Replies

Archiving Router Configuration to TFTP Server Automatically

davidhuynh5
Level 1
Level 1

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

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 ..."

View solution in original post

Joe Clarke
Cisco Employee
Cisco Employee

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.

View solution in original post

5 Replies 5

pompeychimes
Level 4
Level 4

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

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 ..."

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?

Joe Clarke
Cisco Employee
Cisco Employee

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.

i want ask why when i type command "maximum 10" it says "Cannot set maximum when backing up to network path"

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: