TechInfoDepot:Tomato/Backup and Restore config to the same or another router also after nvram reset

From TechInfoDepot
Jump to navigationJump to search

Most people know by now that you should never use your old (previous) config file when you upgrade firmware. Often there are conflicting settings and this can result in some very unpredictable results.

Therefore please note:

  • You must erase NVRAM after flashing new firmware versions and reconfigure.
  • You can't use your previous config, as that would be exactly the same as never having erased NVRAM in the first place.

Also:

And anyone who has tried it will know that a config file from one router cannot be restored onto another. You have to do it another way.

We often want to do this when we buy a new router, for example.

There have been many discussions on how to do this, as normally it's not possible to transfer the config from another router onto a new one. You risk a bricked router if you try editing the file etc. (I know this from experience).

BUT - this is a way to do this which works without the hassle of other methods suggested! You can save the router's configuration in a form where it can be quickly restored to the same or any other tomato router. You do need to "cherry-pick" only the variables that are absolutely necessary to restore.

You need to save a file somewhere on or off the router, with the following command from the command line.

nvram export --set >config.txt

This outputs the complete setup in useable text form, each line beginning with "nvram set". This means it's ready to input to the router without having to add the "nvram set" to every line. You could do this by ssh or telnet.

NOTE - you can only restore the whole config file to the original router. To configure a different router you need to cherry pick the important lines (see below)

e.g.

nvram set clkfreq=480,240,120
nvram set wl0_country=AU
nvram set wan_domain=freewifi
nvram commit

Or - better still:

THE EASIEST WAY TO USE THIS METHOD - SIMPLE CUT AND PASTE!

If you type "nvram export --set" into the "Tools/System command execution box in Teddy Bear's builds (or any version using it as a base) and click "EXECUTE" - it will give you all variables onscreen. These lines can then be individually cut and pasted into the same or even another router's system box and executed. When you are finished, they can then be committed to NVRAM with NVRAM COMMIT, again in the same system box. If you don't commit them, they will be lost when you reboot the router.

It's actually very easy to set up just the important basic config by hand, but cherry pick only the big variables from the text file that are a real pain to do manually (QOS rules, Static DHCP and Access restriction lists in particular).

You can use GREP to find the settings you need.

e.g: experiment with these to get the feel of it:

nvram export --set | grep dhcpd_static
nvram export --set | grep rrule (or rrule1 - and so on)
nvram export --set | grep qos
nvram export --set | grep qos_
nvram export --set | grep qosl
nvram export --set | grep qos_orules

NB - This has the added advantage that you don't re-enter any old unused variables from some long forgotten setup. Often you can reclaim several kilobytes of NVRAM. If you are running short on NVRAM space, try doing this to clean up your space. I often recover up to 10K.

You could also use a small script to send the nvram variables file to a PC cifs share every day using the Scheduler e.g. "nvram export --set >/cifs1/routerconfig.txt". So you can't forget to make a copy of your recent settings.

Nowadays I usually get the list up in a browser window, leave it open, and then cut and paste whatever I need into another browser window on the target router.

It's useful to keep a little script in a text file somewhere so that when you need it, you can collect the relevant details easily by pasting into the system box and execute. Here is one that grabs almost everything I need, for example.

nvram export --set nvram | grep rrule1
nvram export --set nvram | grep qos_
nvram export --set nvram | grep dhcp_
nvram export --set nvram | grep dhcpd_
nvram export --set nvram | grep ddnsx0=
nvram export --set nvram | grep lan_hostname=
nvram export --set nvram | grep lan_ipaddr=
nvram export --set nvram | grep wan_proto=
nvram export --set nvram | grep wan_hostname=
nvram export --set nvram | grep wan_domain
nvram export --set nvram | grep pppoe_username=
nvram export --set nvram | grep pppoe_passwd=
nvram export --set nvram | grep http_
nvram export --set nvram | grep router_name

Try it! It's a doddle... Less than 5 minutes to transfer everything I need and configure a new router.

see also

http://www.linksysinfo.org/forums/showpost.php?p=375128&postcount=538

I think the window is actually big enough to take the complete output, not that I actually use it that way. It's far easier and faster than messing about with telnet, ssh etc.

It's useful to keep a little script in a text file somewhere so that when you need it, you can collect the relevant details easily by pasting into the system box and execute. Here is one that grabs almost everything I need, for example.

nvram export --set | grep rrule1
nvram export --set | grep qos_
nvram export --set | grep dhcp_
nvram export --set | grep dhcpd_
nvram export --set | grep ddnsx0=
nvram export --set | grep lan_hostname=
nvram export --set | grep lan_ipaddr=
nvram export --set | grep wan_proto=
nvram export --set | grep wan_hostname=
nvram export --set | grep wan_domain
nvram export --set | grep pppoe_username=
nvram export --set | grep pppoe_passwd=
nvram export --set | grep http_
nvram export --set | grep router_name