What's new

NVRAM [Release] NVRAM Save/Restore Utility

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Status
Not open for further replies.
Yes. Running option "[5] Update NVRAM Save/Restore Utility Menu" fixed the situation.
amtm never lies, I had a stern talk to about this and other behaviors. You know, things one does when a script comes of age.
 
I appreciate the efforts in writing the script. Helping a lot.
I don't know if there is a possibility to export to .cfg and .tar extensions (jffs)
Code:
settings_$(nvram get buildno)_$(nvram get extendno).cfg
Code:
jffs_$(nvram get buildno)_$(nvram get extendno).tar
I see a way to export to the ownCloud.
nvram-user-sample.sh is an example script that creates a tar backup of the jffs directory created by nvram-save.sh. The script nvram-save.sh will call a user exit script nvram-user.sh at the end of execution. You can rename nvram-user-sample.sh to nvram-user.sh to create the tar file or perform extra processing on the backup files such as move or copy the backup files to another location.

The nvram-save.sh creates a shell script (nvram-restore-202002101120_RT-AC88U-8248.sh) that nvram-restore.sh runs which contains the nvram values saved. The format is not the same as the .cfg backup file saved by the firmware.
 
I changed my USB drive scripts from a USB thumb drive (SNB) to an SSD (WD1tb), by copying all scripts / directories to my Linux box, then copied them to the SSD. I get an error trying to get "nsru" to change to the SSD direcory.

I checked /jffs/configs/profile.add and the alias is there, yet when I type "nsru" it give me the error that it cannot find the old USB thumb drive. How to correct this, please.
Code:
usr_name@RT-AC86U-4608:/jffs/configs# cat profile.add
alias nsru='cd /tmp/mnt/WD1tb/nsru'
alias nsrum='sh /jffs/scripts/nsrum'
Code:
usr_name@RT-AC86U-4608:/tmp/home/root# nsru
-sh: cd: can't cd to /tmp/mnt/SNB/nsru
The profile.add entries get created during installation. If you manually moved the location, the profile.add entries still point to the old location. You will need to edit /jffs/configs/profile.add to reflect the new location and open up a new SSH session for the shortcuts to be recognized.

Using the menu to uninstall will remove the entries from profile.add. Then, run install for the new location. The new location will then get added to profile.add.
 
@Xentrk I'm not having any problems after doing a dirty conversion from ASUS 385.10000 to 384.15, except my NVRAM is dangerously full. After doing some manual cleanup, I managed to get about 2K free. But due to my many dirty updates, I suspect there's many more settings that are left-over from old ASUS days.

I've run your latest nvram_save.sh script. So, I'm wondering if I could purge junk by doing an nvram erase, followed immediately by running the generated nvram-restore-nnnnnnnnnnn.sh . Then commiting.

In my ignorance, I'm hoping the restore script only restores known (current) NVRAM name/value pairs. This assumption comes from the way you've grouped the name/values in specific categories. I also assume that the saved settings are all that are necessary for normal operation. Possibly all or some of the packages might need to be re-installed - but that isn't a big deal.

Sorry if this has already been covered. I've been overwhelmed by all the new stuff I'm dealing with since switching to Merlin and installing all these scripts.
You can use the dhcpstaticlist.sh script to convert dhcp static leases from being stored in nvram to dnsmasq.conf.add to free up additional nvram space.
 
nvram-user-sample.sh is an example script that creates a tar backup of the jffs directory created by nvram-save.sh. The script nvram-save.sh will call a user exit script nvram-user.sh at the end of execution. You can rename nvram-user-sample.sh to nvram-user.sh to create the tar file or perform extra processing on the backup files such as move or copy the backup files to another location.

The nvram-save.sh creates a shell script (nvram-restore-202002101120_RT-AC88U-8248.sh) that nvram-restore.sh runs which contains the nvram values saved. The format is not the same as the .cfg backup file saved by the firmware.
Good. I appreciate your guidance.
 
The profile.add entries get created during installation. If you manually moved the location, the profile.add entries still point to the old location. You will need to edit /jffs/configs/profile.add to reflect the new location and open up a new SSH session for the shortcuts to be recognized.

Using the menu to uninstall will remove the entries from profile.add. Then, run install for the new location. The new location will then get added to profile.add.
That is what I state, /jffs/configs/profile shows the correct path
Code:
user@RT-AC86U-4608:/tmp/home/root# cat /jffs/configs/profile.add 

alias nsru='cd /tmp/mnt/WD1tb/nsru'
alias nsrum='sh /jffs/scripts/nsrum'
typing "nsru" at the command prompt give this wrong path of /tmp/mnt/SNB/ which was the old thumb drive and does not exist any more.
Code:
user@RT-AC86U-4608:/tmp/home/root# nsru
-sh: cd: can't cd to /tmp/mnt/SNB/nsru

I often have 3-5 ssh sessions open, I have closed them all, rebooted the router, still the error shows
Code:
-sh: cd: can't cd to /tmp/mnt/SNB/nsru
 
@Xentrk

FYI ...you have missed the additional NVRAM variables for the VPN Clients - without them, any restore will truncate the VPN Client Custom Configuration GUI, resulting in the failure of the affected VPN Client from correctly initialising.

Also should 'dns_local_cache' be defined?
I didn't have any issues with my testing that caused the failure you describe. Did this occur on an RT-AC86U? I don't have an HND router to test on. But do have remote access to a AC86U at a site I support. But I can't take the router down for testing as it is a business.

I did a check and noticed I was missing the following for each VPN client.
Code:
vpn_clientX_cn
vpn_clientX_gw

Those two nvram parms were empty on my router. I updated merlin.ini to include them.

There were also a few nvram parms missing for some of the nvram parms that start with "vpnc_" that I updated.

I organized all vpn_clientX nvram parms under their respective VPN Client number. For example,
[VPN Client 1], [VPN Client 2], etc...

The nvram VPN Client parms that don't have a number are bundled in the category [VPN Client Admin]

I confirmed that dns_local_cache is in the merlin.ini file.

The updated merlin.ini file can be downloaded by selecting option 2:

[2] Check for updates to existing installation
 

Attachments

  • upload_2020-2-16_8-56-39.png
    upload_2020-2-16_8-56-39.png
    22.4 KB · Views: 217
Last edited:
That is what I state, /jffs/configs/profile shows the correct path
Code:
user@RT-AC86U-4608:/tmp/home/root# cat /jffs/configs/profile.add

alias nsru='cd /tmp/mnt/WD1tb/nsru'
alias nsrum='sh /jffs/scripts/nsrum'
typing "nsru" at the command prompt give this wrong path of /tmp/mnt/SNB/ which was the old thumb drive and does not exist any more.
Code:
user@RT-AC86U-4608:/tmp/home/root# nsru
-sh: cd: can't cd to /tmp/mnt/SNB/nsru

I often have 3-5 ssh sessions open, I have closed them all, rebooted the router, still the error shows
Code:
-sh: cd: can't cd to /tmp/mnt/SNB/nsru
What happens when you type:
Code:
ls -d -- /tmp/mnt/*/nsru
 
The discussion of factory reset and manual restore vs using NVRAM Save/Restore is a good one. The original documentation on the Wiki states some conditions where a manual configuration is recommended rather than using the script.

In the wiki, the statement below states:

Additionally, if incorporating a new router to replace an existing router, even of the same model, the firmware Save/Restore options cannot be used and a fresh setup would be required.

However, that may have been true before the migration mode feature was created.

To exclude the setting from being saved during a migration save, or restored during a migration restore, prefix it with a @. This is only valid for individual settings and is not valid on the section header.

Code:
[System - Basic]
@time_zone_dst
time_zone
time_zone_dstoff

I will take a closer look at what nvram variables may be candidates for not including in a migration restore.

I have used the original utility many times to restore settings after a firmware upgrade and factory reset with no issues. I also used the updated utility to restore after a firmware upgrade followed by a factory reset with no issues. But everyone's situation is different. Everyone should maintain screen prints just in case Murhpy shows up and a manual entry of configs is necessary. I hope forum members will report their experience to see how helpful the utility is to prevent having to perform manual entry of configurations after a firmware update followed by a factory reset.

For those of you who have HND routers, please be aware the running jffs-restore.sh will restore the prior nvram variables stored in /jffs/nvram. Some manual intervention will be required to prevent these from being restored. The step involves navigating to the jffs save/restore file and deleting the /jffs/nvram/ directory or files inside of the /jffs/nvram directory and removing the files you don't want to restore. The only nvram parms that may be an issue is if there are changes to the format of dhcp_staticlist and dhcp_hostnames as was done in 384.13.

The mini script save-mynvram.sh is a small script that can save/restore a small number of user specified nvram settings.
Code:
sh save-mynvram.sh dhcp_hostnames dhcp_staticlist

Saving dhcp_hostnames
Saving dhcp_staticlist
Backing up previous restore script to /tmp/mnt/AC88U/nsru/restore-mynvram.sh.bak

Saved 2 NVRAM variable(s)
Run /tmp/mnt/AC88U/nsru/restore-mynvram.sh to restore your saved settings

I will need to update it to include a check for nvram variables in /jffs/nvram.
 
Last edited:
save-mynvram.sh Code Update

HND models (RT-AC86U and RT-AX88U) store some nvram variables in /jffs/nvram. I pushed an update to the script save-mynvram.sh to also handle any nvram variables stored in /jffs/nvram in addition to the legacy nvram variables. Run option 2 from the installation menu to install the updated version.

One item of interest is all of the nvram variables in /jffs/nvram appear to have an equivalent legacy nvram variable except for dhcp_hostnames.

For example, nvram get dhcp_staticlist and cat /jffs/nvram/dhcp_staticlist should both yield the same values. The only exception appears to be dhcp_hostnames. The command nvram get dhcp_hostnames will return null while cat /jffs/nvram/dhcp_hostnames will have values.

Non HND Router Example:
Code:
sh save-mynvram.sh dhcp_hostnames dhcp_staticlist

Saving NVRAM variable dhcp_hostnames
Saving NVRAM variable dhcp_staticlist
Backing up previous restore script to /tmp/mnt/AC88U/nsru/restore-mynvram.sh.bak

Saved 0 /jffs/nvram variable(s)
Saved 2 NVRAM variable(s)
Run /tmp/mnt/AC88U/nsru/restore-mynvram.sh to restore your saved settings


HND Router Example:
Code:
# sh save-mynvram.sh dhcp_hostnames dhcp_staticlist

Saving /jffs/nvram/dhcp_hostnames
Skipping dhcp_hostnames (empty or does not exist)
Saving /jffs/nvram/dhcp_staticlist
Saving NVRAM variable dhcp_staticlist
Backing up previous restore script to /tmp/mnt/AC88U/nsru/restore-mynvram.sh.bak

Saved 2 /jffs/nvram variable(s)
Saved 1 NVRAM variable(s)
Run /tmp/mnt/AC88U/nsru/restore-mynvram.sh to restore your saved settings
 
Last edited:
I looked at the nvram parameters in nvram-merlin.ini to see what was already excluded from a migration restore (There is a @ in front of the nvram name). lan_hostname is a candidate for removal in a migration restore since it contains an internal reference to the router's model and mac address. All other nvram vars that contain model and firmware versions are not included in the .ini and that makes sense as the firmware sets these values after a factory reset.

If someone updates to a new router and wants to test the NVRAM Save/Restore Utility migration feature and provide feedback, the community would greatly appreciate it.
 
Last edited:
What happens when you type:
Code:
ls -d -- /tmp/mnt/*/nsru
Code:
usr_name@RT-AC86U-4608:/tmp/home/root# ls -d -- /tmp/mnt/*/nsru
/tmp/mnt/WD1tb/nsru
 
Code:
usr_name@RT-AC86U-4608:/tmp/home/root# ls -d -- /tmp/mnt/*/nsru
/tmp/mnt/WD1tb/nsru
The following will remove any references to nsru or nsrum in /jffs/configs/profile.add and create the new short cuts. Copy/paste and run in a command line.

Code:
# Remove all nsru short cuts
sed -i '/nsru/d' "/jffs/configs/profile.add"

# Create new short cut for nsru
echo "alias nsru='cd /tmp/mnt/WD1tb/nsru'" >>/jffs/configs/profile.add

# Create new short cut for nsrum
echo "alias nsrum='cd /jffs/scripts/nsrum'" >>/jffs/configs/profile.add
Test by opening a new SSH session and typing the commands nsru and nsrum.
 
Code:
MD5 hash of clear-maclist.sh matches - skiping download clear-maclist.sh
Typo: "skiping" -> "skipping".
Thanks. Fixed.
 
The following will remove any references to nsru or nsrum in /jffs/configs/profile.add and create the new short cuts. Copy/paste and run in a command line.

Code:
# Remove all nsru short cuts
sed -i '/nsru/d' "/jffs/configs/profile.add"

# Create new short cut for nsru
echo "alias nsru='cd /tmp/mnt/WD1tb/nsru'" >>/jffs/configs/profile.add

# Create new short cut for nsrum
echo "alias nsrum='cd /jffs/scripts/nsrum'" >>/jffs/configs/profile.add
Test by opening a new SSH session and typing the commands nsru and nsrum.
Thanks for the reply. We are still going in circles. Those lines to be added after deletion are what is already there!
Code:
user@RT-AC86U-4608:/tmp/home/root# cat /jffs/configs/profile.add

alias nsru='cd /tmp/mnt/WD1tb/nsru'
alias nsrum='sh /jffs/scripts/nsrum'
When I run the command to cd to the nsru directory, I finds the old path that is not there. That USB thumb drive was removed from the router and it has since rebooted twice and obviously all ssd sessions closed. My Linux computer that I use to ssh into the router has also been rebooted twice.

The ghost in the machine still haunts my AC86U.
Code:
user@RT-AC86U-4608:/tmp/home/root# nsru
-sh: cd: can't cd to /tmp/mnt/SNB/nsru
 
Thanks for the reply. We are still going in circles. Those lines to be added after deletion are what is already there!
Code:
user@RT-AC86U-4608:/tmp/home/root# cat /jffs/configs/profile.add

alias nsru='cd /tmp/mnt/WD1tb/nsru'
alias nsrum='sh /jffs/scripts/nsrum'
Ah. Okay. I don't have an answer at the moment then. Have you ever had aliases work in /jffs/configs/profile.add before?

If you don't have too many entries in /jffs/configs/profile.add, you can try downloading the profile.add I created and host on GitHub.

install profile.add
Code:
/usr/sbin/curl --retry 3 "https://raw.githubusercontent.com/Xentrk/Asuswrt-Merlin-Linux-Shell-Scripts/master/profile.add" -o "/jffs/configs/profile.add"

Then, install the utility directly from the cmd line:
Code:
/usr/sbin/curl --retry 3 "https://raw.githubusercontent.com/Xentrk/nvram-save-restore-utility/master/nsrum" -o "/jffs/scripts/nsrum" && sleep 5 && chmod 755 /jffs/scripts/nsrum && sh /jffs/scripts/nsrum
Select option 1 to install. The short cuts should then get created. Open a new SSH session and see if the aliases work. Following are some of the aliases and functions:

Code:
#help

Command List:

Chk_ADNS      List OpenVPN DNS Settings
clients       List hostname, IP address and MAC address for LAN clients
js            cd /jffs/scripts
jc            cd /jffs/configs
ld            cd /opt/var/log
liststats     List number of entries in each IPSET list
listiface     List status of WAN and OpenVPN interfaces
MatchIP       Check IP against IPSET lists to see if the IP address exists
              Usage: MactchIP 111.222.333.444
purge_routes  Purge policy routing rules
routes        Alternative to 'ip routes' command
tree          Similar to the Unix 'tree' command to list directories
ltree         List directories and files in each directory
 
Ah. Okay. I don't have an answer at the moment then. Have you ever had aliases work in /jffs/configs/profile.add before?

If you don't have too many entries in /jffs/configs/profile.add

I believe so, but I have never dug this deeply into that file. I had the same AMTM issues that others had on update earlier this week, and run the "unalias amtm" to resolve that as posted here.

The cat /jffs/configs/profile.add is complete here.
Code:
user@RT-AC86U-4608:/tmp/home/root# cat /jffs/configs/profile.add

alias nsru='cd /tmp/mnt/WD1tb/nsru'
alias nsrum='sh /jffs/scripts/nsrum'

I will delete the nsrum installation and try those suggestions above later today when I have time. Thank you.
 
You can use the dhcpstaticlist.sh script to convert dhcp static leases from being stored in nvram to dnsmasq.conf.add to free up additional nvram space.
Thanks for the reference to the dhcpstaticlist.sh script. I knew something like that existed (from casual reading of SNB Merlin forum), but didn't remember the name or any details.
Running it, I see that my dhcp_staticlist only uses 1051 bytes (after some cleanup in the WebGui), I don't think I'll move it to dnsmasq.conf at this time. I've managed to get my NVRAM usage down to 63300 (still high enough to trip that "!" warning in the Gui), so I'll still keep looking for other things to purge. But there's no emergency.

Related to this purge, in NVRAM on my 68U, I notice there are two maclists for each interface (ex: wl1.1_maclist and wl1.1_maclist_x). Same MACs, different format. I assume one is an obsolete hold-over from older firmware. Assuming this is an example of obsolete settings, is it safe to unset the old one?
 
Last edited:
I believe so, but I have never dug this deeply into that file. I had the same AMTM issues that others had on update earlier this week, and run the "unalias amtm" to resolve that as posted here.

The cat /jffs/configs/profile.add is complete here.
Code:
user@RT-AC86U-4608:/tmp/home/root# cat /jffs/configs/profile.add

alias nsru='cd /tmp/mnt/WD1tb/nsru'
alias nsrum='sh /jffs/scripts/nsrum'

I will delete the nsrum installation and try those suggestions above later today when I have time. Thank you.
The only other thing I can think of is to try a different SSH client. I use MobaXterm.
 
Status
Not open for further replies.

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top