Best Way to Backup Changed Settings / Configuration Only

Discussion in 'Tomato Firmware' started by Boktai1000, Feb 9, 2019.

  1. Boktai1000

    Boktai1000 Network Guru Member

    Hello,

    I am inquiring to find out what is the best way to capture only settings that have been changed from the default options, and if that is even possible?

    My goal here is to build out a "nvram settings" config cheat sheet to have on hand any time I do an NVRAM erase, so that I'm able to quickly apply my configuration back to the router. I would prefer not to simply reapply an NVMRAM config restore, but instead apply one line (or multiple lines) copy/pasted back into the CLI to apply the settings.

    In addition I have previously always configured my settings through the GUI. I would like to learn the command line equivalent of these settings and be more familiar with the NVRAM equivalent options.

    If it is not possible to export only changed settings, what would be the best way for me to capture changes that I've made already, especially if I'm unsure all of the changes and wanted to make sure I captured everything?

    Any good resources or tips and tricks, or ways other users are doing this would be appreciated as I don't necessarily want to re-invent the wheel here.

    Thank you
     
  2. JeffD

    JeffD Serious Server Member

    First off, I love the idea. But you may be barking up the wrong tree. The NVRAM tools support an export which generates the SET command used for setting the values. So, you run this on your router pipe that to a file and then save that file off for if you need to restore. I think it's just that simple. There's no harm setting the default value to the default values, it's basically a no-cost thing to do.

    You can do something like this from the shell which generates a list of set commands which can be used to restore settings. If you pipe this to a file and save that you can restore NVRAM executing that those commands:
    Code:
    nvram export --set
    There's also a --nodefaults option which I think may do what you want, but I'm no expert on the nvram tool.
    Code:
    nvram export --set --nodefaults
    My --nodefaults run was roughly 1000 less lines of values, but I have no way of knowing if this is what you're really looking for.
    EDIT: After looking at the nvram source code it looks like this will do what you want because before exporting the value it compares it against the default defined in firmware. You may still want to test it, but I think it's what you're looking for.

    The place where I ran into problems is that I'd like to do something similar except clone settings from router1 to router2. This gets a little more difficult because there are device specific values (MAC, Serial Number, Model Number, etc) which shouldn't be changed from the values populated by default.


    The other option I was thinking tp suggest would work if you're a programmer.... You could use your export file and with python or perl or some other language write a script which would compare your exported values against the defaults defined in defaults.c file for your firmware's source code to see what's different.
     
    Last edited: Feb 10, 2019
  3. cbunt1

    cbunt1 Serious Server Member

    I don't know how much help this offers, but I setup a script some time ago (several versions ago) as an exercise to get my back into scripting. It's crude, and probably more complicated than it needed to be.

    It was also a purpose-built set of tools; I had several routers running Tomato (Shibby) that I wanted to hot-swap as I changed configs, or to provide a depot-style swap when something went wrong on a router...and the built-in tools prevented me from moving configs from one router to another...my scripts were designed to strip the hardware info that was causing a problem.

    Anyway, all that to say: Have a look at https://github.com/cbunt1/BTRMS. It may give you a good starting point, and may even work for what you need.
     
  4. Boktai1000

    Boktai1000 Network Guru Member

    Hey guys,

    I just wanted to follow up on this as I finally had a chance to give this a go for a firmware upgrade. Unfortunately what I came across is that
    Code:
    nvram export --set
    and
    Code:
    nvram export --set --nodefaults
    Do not work on ARM based routers. It appears that nvram export --set is a MIPS specific command after doing a bit of reading, so I believe the BTRMS script would not function either since I saw that command script referenced, but didn't personally try it.

    I ended up posting over on Reddit about this ( https://www.reddit.com/r/TomatoFTW/comments/aouxwg/backing_up_inuse_configuration_changes_and/ ) and a user replied to my thread with a Python 3 script that he made to extracts values and compares from a default config against your running config, which you need to provide both for.

    I know for sure that this works on ARM, but presumably this would also work on MIPS (but that's untested by myself). Anyways I just wanted to share these results to you and to anyone else that may come across this.

    His script can be located here: https://github.com/NotVaryClever/tomato-nvram

     
    ddimitrov and cbunt1 like this.
  5. jerrm

    jerrm Network Guru Member

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice