Configuration Archiving


You want to automatically maintain an archive of router configuration files.


To create an archive of old configuration files, use the following set of commands:

Router1#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config-archive)#path slot0:/configs/$h
Router1(config-archive)#time-period 1440



Starting with IOS Version 12.3(4)T, Cisco introduced the ability to archive IOS configuration files. Once the feature is enabled, the router's configuration is stored in the archive each time you issue a write memory or copy running-config startup-config. In our example, we chose to save the archive configuration files on the flash card in slot0; however, you can also store the configuration files remotely using such protocols as TFTP.

Before the router can store the files in the location we've configured, we first need to create the directory configs. You don't need to store the archive files within a directory, but it's a good idea to keep the archive files together and away from other files such as IOS images. To create a directory in flash, use the mkdir command:

Router1#cd slot0:
Router1#mkdir configs
Create directory filename [configs]? 
Created dir slot0:/configs

Once the directory is created, the router will begin to automatically store its router configuration files each time you save the configuration file to NVRAM. In addition, you will notice that we configured a periodic archive every 1,440 minutes, or once a day. This is purely optional, but is a nice feature to enableespecially if you're saving the router configuration files to a remote server.

To view the archive configuration, use the show archive command:

Router1#show archive
There are currently 5 archive configurations saved.
The next archive file will be named slot0:/configs/Router1-5
 Archive # Name
 1 slot0:/configs/Router1-1 
 2 slot0:/configs/Router1-2 
 3 slot0:/configs/Router1-3 
 4 slot0:/configs/Router1-4 <- Most Recent

Notice that we already have five archived configurations saved. Also notice the name of each file begins with the hostname and has a suffix of "-" and a number. If you recall, we configured the path to include "$h", which automatically uses the hostname to name the archive files. You can choose to explicitly name the archive files yourself but this provides a nice easy way to name the files, especially if you're configuring a group or routers at once using a script. You can also choose to include a date/time stamp in the filename as well by including the "$t" variable in the filename:

Router1(config-archive)#path slot0:/configs/$h$t

The file numbering is automatically tagged on to the end of each filename to ensure uniqueness and allow you to determine the order of creation. By default, 14 archive files are stored; however, you can adjust the number of archive files by using the maximum command:

Router1#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config-archive)#maximum 10

The router automatically overwrites the oldest archive once the maximum number of archives is reached to ensure you always have the more recent archive files available.

Another useful feature of maintaining a configuration files archive is the ability to view the differences between archive files and the ability to perform a configuration rollback. For instance, to view the configuration differences between the current running configuration and a particular archive file, use the following command:

Router1#show archive config differences slot0:/configs/Router1-1
Contextual Config Diffs:
+ip cef
-no ip cef


In this simple example, the only difference is that we've disabled ip cef. Notice that commands added to the configuration file are marked with a "+" sign and commands removed from the file are marked with a "-" sign.

Say you wish to resort back to a previous configuration archive file. We recommend that you first store the current running configuration file by using the archive config EXEC command, and then issue the configure replace command. In the next example we chose to roll back the configuration to the archive file named "Router1-1":

Router1#archive config
Router1#configure replace slot0:/configs/Router1-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


This is a nice feature, since it provides an elegent method of rolling back the configuration file in case you make a mistake or a new feature didn't work as planned.

See Also

Recipe 1.18

Router Configuration and File Management

Router Management

User Access and Privilege Levels


IP Routing





Frame Relay

Handling Queuing and Congestion

Tunnels and VPNs

Dial Backup

NTP and Time


Router Interfaces and Media

Simple Network Management Protocol





First Hop Redundancy Protocols

IP Multicast

IP Mobility




Appendix 1. External Software Packages

Appendix 2. IP Precedence, TOS, and DSCP Classifications


Cisco IOS Cookbook
Cisco IOS Cookbook (Cookbooks (OReilly))
ISBN: 0596527225
EAN: 2147483647
Year: 2004
Pages: 505 © 2008-2020.
If you may any questions please contact us: