Archiving and restoring Cisco configuration
May 17, 2017
Have you ever been in a situation that, you typed many commands on your Cisco device and after that you came to conclusion that your new configuration does not work as you expected?
There is no obvious way to restore your previous configuration. Even if you keep the backup of your configuration the copy backup-config running-config command merges the backup configuration with the running configuration (not restore it).
Fortunately Cisco offers a way to archive (backup) and restore your configuration in a smart way. The archive feature can be used to find differences between your archive and running configuration and apply the commands which effectively restore your archive configuration.
Here is the configuration snippet with my commentary.
R1(config)#archive // Configure archive location. I give two examples (for tftp and flash). The first archive file // will be named router-backup-1; next one router-backup-2, etc. R1(config-archive)#path tftp://192.168.0.106/router-backup R1(config-archive)#path flash:router-backup // Create archive every time a configuration is saved and every 24 hours (1440 minutes) R1(config-archive)#write-memory R1(config-archive)#time-period 1440 // Every time you save your configuration the archive file will be created R1#write (...) // you can see all your archives R1#show archive The next archive file will be named tftp://192.168.0.106/router-backup-3 Archive # Name 0 1 tftp://192.168.0.106/router-backup-1 2 tftp://192.168.0.106/router-backup-2 (...) // compare archives R1(config)# show archive config differences tftp://192.168.0.106/router-backup-1 tftp://192.168.0.106/router-backup-2 (...) // restore archive configuration R1#configure replace tftp://192.168.0.106/router-backup-1 This will apply all necessary additions and deletions to replace the current running configuration with the contents of the specified configuration file, which is assumed to be a complete configuration, not a partial configuration. Enter Y if you are sure you want to proceed. ? [no]: Y Loading router-backup-1 from 192.168.0.106 (via FastEthernet1/0): ! [OK - 1262 bytes] *Mar 1 00:25:58.779: Rollback:Acquired Configuration lock. *Mar 1 00:26:16.779: %LINK-5-CHANGED: Interface Loopback0, changed state to administratively down *Mar 1 00:26:16.979: %LINK-5-CHANGED: Interface Loopback2, changed state to administratively down *Mar 1 00:26:17.795: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to down *Mar 1 00:26:17.999: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback2, changed state to down Total number of passes: 1 Rollback Done