Friday, September 4, 2009

Backup & Restore IOS and Configs

As with any aspect of computer data, the IOS and the router configs need backing up. This is pretty simple and in this post post I'll show a few different ways of doing this.



Backing Up

First the easy way. Copy and Paste.

Using the show commands you can output the running-config or the startup-config to screen. This config can be copied and pasted directly into a text file. In Windows use Wordpad as it keeps the formatting better.

Router#show running-config


You need to copy everything from and including the exclamation mark under the line "Current Configuration" to the last line (and including) which starts with "end".

And when you are restoring it just get yourself into configure mode (Configure Terminal) and paste it back in. Simple!


Now using TFTP.

Get yourself something running a TFTP Server. A nice free one is TFTPd32.
From your router make sure you have connectivity to your TFTP Server by pinging it. Then we use the Dir command to check the IOS name and the copy command to copy the IOS and the config to our TFTP Server.

Router#dir flash:
Router#copy flash:c831-k9o3y6-mz.124-4.T1.bin tftp
Address or name of remote host []? 10.0.1.11
Destination filename [c831-k9o3y6-mz.124-4.T1.bin]?
Router#copy startup-config tftp://10.0.1.11/startup-config
Address or name of remote host [10.0.1.11]?
Destination filename [startup-config]?


So in the example above, for the IOS i just specify I want to copy the file to TFTP. I then get prompted for an IP Address and asked to confirm the filename by pressing enter.

For the Startup-Config I specify the TFTP server and filename after the copy command. This way I only get asked to press enter to confirm both the IP and the filename.

And below I can see the progress of my copy to the TFTP Server.




One final note on backing up. Recently I was having an issue with the NVRAM holding my startup-config and I got tired of hooking up my TFTP Server. So I copied it to flash and simply restored it to running-config from there using the following command:

Router#copy flash:startup-confg running-config


Restoring

Restoring is just really the oposite. To grab the config from a TFTP server I would use:
copy tftp://10.0.1.3/startup-config running-config
or for the IOS:

copy tftp://10.0.1.3/ios-file-name.bin flash:ios-file-name.bin

The only points here are:
  • If your IOS is larger than the free space in flash it will overwrite the existing IOS in flash. But be sure not to reboot a router between deleting an IOS file from flash and restoring the new one.
  • After restoring a config all interfaces are placed in a shutdown state.
  • Restored configs merge into existing configs so if this isn't what you want use the erase command before restoring.

No comments: