Today I was chatting on IRC with some colleagues, and we were trying to come up with the best way to roll back to the startup-config without a reboot. This would be useful in situations where you are working remotely and may potentially lose access to the device you are configuring.
The best method I came up with was to use the Kron command:
kron occurrence RELOAD-CONFIG in x oneshot
policy-list RELOAD-CONFIG
!
kron policy-list RELOAD-CONFIG
cli configure replace nvram:startup-config force
!
Where x is the number of minutes before the configuration refresh.
Very nice when you can’t afford the downtime of having your device reboot, especially a device like a 6500 that just seems to take for ever to come back up fully.
Edit:
I decided to try to see if I could run it using one command. TCL could be used, but honestly… TCL for 4 lines? That’s just… silly. So instead I used a combination of macros and aliases:
switch#
switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
switch(config)#macro name refresh_config
Enter macro commands one per line. End with the character '@'.
kron occ CFG in 2 oneshot
policy-list CFG
kron policy-list CFG
cli configure replace nvram:startup-config force
@
switch(config)#alias configure ref macro global apply refresh_config
switch(config)#do sh run | i ipv6
switch(config)#ref
Kron: Policy Accepted, Policy CFG needs to be configured
switch(config)#ipv6 unicast-routing
switch(config)#end
switch#sh
00:40:26: %SYS-5-CONFIG_I: Configured from console by conso
switch#sh run | i ipv6
ipv6 unicast-routing
switch#sh kron sch
Kron Occurrence Schedule
CFG inactive, will run once in 0 days 00:01:22
switch#sh kron sch
Kron Occurrence Schedule
CFG inactive, will run once in 0 days 00:00:58
switch#sh kron sch
Kron Occurrence Schedule
CFG inactive, will run once in 0 days 00:00:24
switch#sh kron sch
Kron Occurrence Schedule
CFG inactive, will run once in 0 days 00:00:05
switch#
00:42:16: Rollback:Acquired Configuration lock.
switch#sh kron sch
Kron Occurrence Schedule
switch#sh run | i ipv6
switch#
Just as convoluted, and just as pointless. But it IS do-able. But again, for 4 lines, it’s not worth the effort.