The configure
replace privileged EXEC command provides the capability to replace the current running configuration with any saved Cisco IOS configuration
file. This functionality can be used to revert to a previous configuration state, effectively rolling back any configuration
changes that were made since the previous configuration state was saved.
When using the configure
replace command, you must specify a saved Cisco IOS configuration as the replacement configuration file for the current running configuration.
The replacement file must be a complete configuration generated by a Cisco IOS device (for example, a configuration generated
by the copy
running-config
destination-url command), or, if generated externally, the replacement file must comply with the format of files generated by Cisco IOS devices.
When the configure
replace command is entered, the current running configuration is compared with the specified replacement configuration and a set
of diffs is generated. The algorithm used to compare the two files is the same as that employed by the show
archive
config
differences command. The resulting diffs are then applied by the Cisco IOS parser to achieve the replacement configuration state. Only
the diffs are applied, avoiding potential service disruption from reapplying configuration commands that already exist in
the current running configuration. This algorithm effectively handles configuration changes to order-dependent commands (such
as access lists) through a multiple pass process. Under normal circumstances, no more than three passes are needed to complete
a configuration replace operation, and a limit of five passes is performed to preclude any looping behavior.
The Cisco IOS copy
source-url
running-config privileged EXEC command is often used to copy a stored Cisco IOS configuration file to the running configuration. When using
the copy
source-url
running-config command as an alternative to the configure
replace
target-url privileged EXEC command, the following major differences should be noted:
-
The copy
source-url
running-config command is a merge operation and preserves all of the commands from both the source file and the current running configuration.
This command does not remove commands from the current running configuration that are not present in the source file. In contrast,
the configure
replace
target-url command removes commands from the current running configuration that are not present in the replacement file and adds commands
to the current running configuration that need to be added.
-
The copy source-url
running-config command applies every command in the source file, whether or not the command is already present in the current running configuration.
This algorithm is inefficient and, in some cases, can result in service outages. In contrast, the configure replace
target-url command only applies the commands that need to be applied—no existing commands in the current running configuration are reapplied.
-
A partial configuration file may be used as the source file for the copy
source-url
running-config command, whereas a complete Cisco IOS configuration file must be used as the replacement file for the configure replace
target-url command.
A locking feature for the configuration replace operation was introduced. When the configure replace command is used, the running configuration file is locked by default for the duration of the configuration replace operation.
This locking mechanism prevents other users from changing the running configuration while the replacement operation is taking
place, which might otherwise cause the replacement operation to terminate unsuccessfully. You can disable the locking of the
running configuration by using the no lock keyword when issuing the configure replace
command.
The running configuration lock is automatically cleared at the end of the configuration replace operation. You can display
any locks that may be currently applied to the running configuration using the show configuration lock command.