Automatically backup your Cisco IOS configurations


So you have your router and switches all setup the way you want and everything is running smoothly within your network. Then one day it happens. Your router has a hardware failure and needs to be replaced. You expedite the replacement, mount it in the rack, power her up, and then realize that you don’t have a copy of the most recent configuration or worse yet, you don’t have a copy at all!

Of course this can be avoided by manually copying the running configuration for safe keeping, but we like automatic. The kind of automatic that we don’t have to worry about. The kind of automatic that Cisco provided to us with the ‘archive’ command starting with the IOS versions shown in Table A.

Release
Modification

12.3(7)T

This command was introduced.

12.2(25)S

This command was integrated into Cisco IOS Release 12.2(25)S.

12.2(28)SB

This command was integrated into Cisco IOS Release 12.2(28)SB.

12.2(33)SRA

This command was integrated into Cisco IOS Release 12.2(33)SRA.

12.2(31)SB2

This command was implemented on the Cisco 10000 series.

12.2(33)SXH

This command was integrated into Cisco IOS Release 12.2(33)SXH.

12.2(33)SB

This command was integrated into Cisco IOS Release 12.2(33)SB and implemented on the Cisco 10000 series.

Table A: Archive command release history from Cisco.

The archive command allows you to create a copy of your configuration manually, periodically, or when the configuration is stored in NVRAM via FTP, TFTP, HTTP, or RCP.

In this example, I’ll being configuring the router to copy the configuration to a Windows 2003 FTP server  every time the ‘write memory’ command is issued. The file name is built on the routers host name, appended with “-x”, where “x” is an incremental number.  I’m also using the credentials of an Active Directory user, that I created for this purpose,  to allow the router to connect to the FTP server.

The FTP server address is: 192.168.1.50
Username: stevenson\netadmin
Password: n3t4dm1n

First we’ll configure the router with the FTP username and password.

Router(config)# ip ftp username stevenson\netadmin
Router(config)# ip ftp password n3t4dm1n

Now execute the ‘archive’ command.

Router(config)# archive

Now specify the path for the configuration archives

Router(config-archive)# path ftp://192.168.1.50/$h
Router(config-archive)# write-memory

The &h in the path instructs the system to use the hostname of the router when naming the archived configuration. And write-memory causes the configuration to be archived each time the write memory command is issued.

That’s it! You now have your router setup to automatically archive/copy your most recent configuration file to an FTP server for safe keeping. To test it out either enter:

Router# write memory

or

Router# archive config

Now check your FTP server and you should find the archived copy of your routers configuration.

If you want the router to archive your configuration at a desired interval, you can do that too by using the time-period command followed by the number of minutes that you want the archiving to wait between archive creation.

Router(config-archive)# time-period 10080

If you want to see a list of archives with the most recent highlighted, simply use this command:

Router# show archive

Now that you have the configuration backed up and can see the listed archives, lets look at restoring from one of the archived configuration files. Decide which archive file that you want to restore, from the list you saw when you issued the show archive command and enter that name as shown:

Router# configure replace ftp://192.168.1.50/Router-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
Total number of passes: 1
Rollback Done

After you see “Rollback Done”, your selected archived configuration is now back in place on your router.

I’ve deployed this solution to a mix of Cisco routers, switches, and voice gateways and let me tell ya, it’s a nice feeling to know that all of those configs are being backed up automatically. Now if I have a failure or issue a bad command I can quickly and easily get things back to the way they were previously.