As a Network admin there will be more than one instance when we hit a state where we need to rollback to a previous configuration. In Cisco Switches and Routers this can be done using the configure replace command.
Cisco IOS 12.3 and later supported the new feature called Configuration Replace and Configuration Rollback where by the last saved configuration can be rolled back to the running config.
If you have saved the config after you have made change and then try to rollback, you can still survive if you had a backup config elsewhere like a tftp, ftp location or a HTTP, RCP and SCP server as long as it is a valid Cisco IOS configuration file .
The Configuration Roll back feature in Cisco will run a diff against the saved config and the running config and apply only the difference to the running config as against the copy command. This copy startup-config running-config command merges the running config and the startup config and when there is a diff Running-config takes precedence.
The following command will simply replace the Running-Config with the Startup-Config saved in the NVRAM with the last saved configurartion:
Router(config)# configure replace nvram:startup-config
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
To force apply without the confirmation message:
Router(config)# configure replace nvram:startup-config force
Total number of passes: 1
If the config is saved elsewhere then that can be used in the above command instead of the nvram:startup-config
Router(config)# configure replace tftp://192.168.1.1/saved-cfg
The Syntax for the command is
Router(config)# configure replace <TargetURL> list force time <time in sec> nolock
TargetURL – is the location and the file from where the config is being rolled back.
list – Lists the command lines applied by the Cisco IOS software parser during each pass of the configuration replace operation. The total number of passes performed is also displayed.
force – Forces the config replacement without prompting for a confirmation
time – Time to wait for the configure confirm command before reversing the changes of the configure replace operation.
nolock – Disables the locking feature on Cisco IOS which prevents other users from modifying the running config.
For more details, click here for the Cisco official documentation