How to compare 2 Nvrambak bin files to see difference

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
00diabolic
DD-WRT User


Joined: 17 Aug 2011
Posts: 78

PostPosted: Wed Apr 21, 2021 22:23    Post subject: How to compare 2 Nvrambak bin files to see difference Reply with quote
Hi all,

Is there a way to compare 2 bin file backups from nvram backup? I tried to open the bin file from notepad and its kinda ugly and I dont want to mess it up by editing in notepad. SO I was wondering if there is a way to do this so I can see the difference between 2 backups?

Just to outline, id rather not here I should not be using NVrambackups and should be using SSH or some other settings backup method. I just want to focus on how to compare different files.
Sponsor
Wildlion
DD-WRT Guru


Joined: 24 May 2016
Posts: 1413

PostPosted: Wed Apr 21, 2021 22:48    Post subject: Reply with quote
nvram is in a binary format...

People have asked this on the forum before:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=33164

I cannot vouch for the tool as I have never used it and it is probably old so it may be missing new params.

otherwise log in to the system via command line and do nvram show for each (after loading) to compare but make sure you are on correct version of firmware

The other aspect is that due to how they are written, they may not be in the same order each time you write out.. (ie because the usage statistics move)
00diabolic
DD-WRT User


Joined: 17 Aug 2011
Posts: 78

PostPosted: Thu Apr 22, 2021 15:54    Post subject: Reply with quote
Wildlion, Thanks for pointing this out, damn over 10yr old thread no wonder I did not find it.

I have a tool called Beyond compare that I was going to try with just the bin file straight but at least with this tool I can convert it to CSV and compare that way. I have a adblock setup on a previous DDWRT install that works and when I simply copy over the settings manually I cant figure out what I keep missing. The adblock does not work anyway this is why I wanted to compare the settings to see what I was missing. My DDWRT setup keeps getting more and more complicated and its harder and harder to catch mistakes when manually moving over settings, one thing gets missed and it wont work.
00diabolic
DD-WRT User


Joined: 17 Aug 2011
Posts: 78

PostPosted: Thu Apr 22, 2021 16:06    Post subject: Reply with quote
Darn, just gave it a try after converting to CSV and comparing the 2 CSV files all the lines are in different positions which is what one of the guys said might happen. I guess its back to square one. There has to be a different way to do this or a simpler way to backup setting between builds.
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14216
Location: Texas, USA

PostPosted: Thu Apr 22, 2021 18:25    Post subject: Reply with quote
You could just do an nvram show | sort, copy, paste into a text file, diff.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
00diabolic
DD-WRT User


Joined: 17 Aug 2011
Posts: 78

PostPosted: Thu Apr 22, 2021 20:39    Post subject: Reply with quote
kernel-panic69 wrote:
You could just do an nvram show | sort, copy, paste into a text file, diff.


Ok I know Nvram show is a SSH command but the output i'm getting is only the other commands I use for startup/firewall and shutdown, nothing else. Maybe im doing something wrong. Can you give me a bit more of a how to?
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14216
Location: Texas, USA

PostPosted: Thu Apr 22, 2021 21:24    Post subject: Reply with quote
If you ssh or telnet into the router, and issue an 'nvram show | sort' (no quotes), it should give you the entire output of your nvram contents. I don't know of any routers this is broken on.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
00diabolic
DD-WRT User


Joined: 17 Aug 2011
Posts: 78

PostPosted: Fri Apr 23, 2021 15:30    Post subject: Reply with quote
kernel-panic69 wrote:
If you ssh or telnet into the router, and issue an 'nvram show | sort' (no quotes), it should give you the entire output of your nvram contents. I don't know of any routers this is broken on.


Ok ill try it through SSH client on windows, I tried with the DDWRT app on android to see if it worked and got odd results.

Once I copy and paste it to text can i restore NVram the same way? pasting it back in? whats the command the write it?
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Fri Apr 23, 2021 22:56    Post subject: Reply with quote
Of course you'll get odd results... the entire Startup window is in nvram variable rc_startup. Likewise all of the Firewall window is in rc_firewall. Additional DNSMasq Commands is in a variable, as are the ssh keys, as is the OpenVPN client's Additional Config. So if your configuration is at all interesting, the nvram show will give you things not entirely easy to reverse (without some work by hand) to restore stuff, and of course a sort will scramble things without mercy.
_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
00diabolic
DD-WRT User


Joined: 17 Aug 2011
Posts: 78

PostPosted: Sun Apr 25, 2021 15:55    Post subject: Reply with quote
SurprisedItWorks wrote:
Of course you'll get odd results... the entire Startup window is in nvram variable rc_startup. Likewise all of the Firewall window is in rc_firewall. Additional DNSMasq Commands is in a variable, as are the ssh keys, as is the OpenVPN client's Additional Config. So if your configuration is at all interesting, the nvram show will give you things not entirely easy to reverse (without some work by hand) to restore stuff, and of course a sort will scramble things without mercy.


Yeah this makes sense after what I saw. So its not going to be able to paste and write the NVRAM via SSH?
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Sun Apr 25, 2021 21:15    Post subject: Reply with quote
00diabolic wrote:
SurprisedItWorks wrote:
Of course you'll get odd results... the entire Startup window is in nvram variable rc_startup. Likewise all of the Firewall window is in rc_firewall. Additional DNSMasq Commands is in a variable, as are the ssh keys, as is the OpenVPN client's Additional Config. So if your configuration is at all interesting, the nvram show will give you things not entirely easy to reverse (without some work by hand) to restore stuff, and of course a sort will scramble things without mercy.


Yeah this makes sense after what I saw. So its not going to be able to paste and write the NVRAM via SSH?

I don't know a way to do a bulk write of all settings using the output of nvram show. You can easily do nvram set foo='bar' commands in ssh of course, and if you look at the last link in my sig below, the "Edit GUI windows..." one, you can see my tools for linux people to maintain the big windows like Startup and Firewall on a computer from which they can be uploaded to nvram in the router when they change. Not sure how Windows people would do something similar.

And certainly one can cook up makefiles to do the heavy lifting if you have multiple routers to maintain. I've done it here but was surprised at what a "house of cards" it turned out to be. Too messy to share. Maybe someone else can do better.

_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
00diabolic
DD-WRT User


Joined: 17 Aug 2011
Posts: 78

PostPosted: Tue Apr 27, 2021 15:05    Post subject: Reply with quote
SurprisedItWorks wrote:
00diabolic wrote:
SurprisedItWorks wrote:
Of course you'll get odd results... the entire Startup window is in nvram variable rc_startup. Likewise all of the Firewall window is in rc_firewall. Additional DNSMasq Commands is in a variable, as are the ssh keys, as is the OpenVPN client's Additional Config. So if your configuration is at all interesting, the nvram show will give you things not entirely easy to reverse (without some work by hand) to restore stuff, and of course a sort will scramble things without mercy.


Yeah this makes sense after what I saw. So its not going to be able to paste and write the NVRAM via SSH?

I don't know a way to do a bulk write of all settings using the output of nvram show. You can easily do nvram set foo='bar' commands in ssh of course, and if you look at the last link in my sig below, the "Edit GUI windows..." one, you can see my tools for linux people to maintain the big windows like Startup and Firewall on a computer from which they can be uploaded to nvram in the router when they change. Not sure how Windows people would do something similar.

And certainly one can cook up makefiles to do the heavy lifting if you have multiple routers to maintain. I've done it here but was surprised at what a "house of cards" it turned out to be. Too messy to share. Maybe someone else can do better.


What does nvram set foo='bar' Do? I guess Ill keep doing everything manually. We constantly need to upgrade our routers primarily for security but there is no good way to transfer 100's, no wait 1000's of settings from one ddwrt version to another and to me that is the biggest issue with DDWRT bar none.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum