What's new

User NVRAM Save/Restore Utility (R26.2)

  • 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.
Got it....it's the double quotes causing the problem. Thanks for the reporting it. Will have a fix in the next release.

Thanks, great tool anyway. It saved my life regarding the openvpn static key configuration in recent releases, i used your tool to change a static key in the gui were i was not able to do it in another way (of what i was awared of). :)
 
Thank you john9527 for the user script.
This is very helpful, now I'll be able to automate backup :)

Looking for new releases with more features.
Continue on that way!
 
The restore script does an 'nvram commit' at the end so everything should be saved to nvram. I don't think it would take long enough that you could reboot before it's finished, but I'll add a short delay to give it some extra time (make sure you see the 'Please reboot' message at the end of the restore).



Sorry, but the script and data have to be on a drive local to the router. You can however share the flash drive via SAMBA and access it from Windows that way to copy files. Or, get a copy of WinSCP which will let you have the router flash drive directory side by side with a PC directory and drag and drop between them.

SCP might be your solution. This is what I am using to transfer files. I can also do it with Samba however prefer SCP ...
Advantage of SCP is if you have an SSH server on your Windows, you can automate the transfer to Windows as well. A little bit configuration is required however feasible :)
 
I'm trying to keep things as simple as possible for all users, so not included in the base function.

But, I did add a user script option where you can add this function if you want (BTW, bzip2 isn't included in the firmware build, you have to use gzip).
Documented at the end of the QuickStart under 'Advanced Users'.

Regarding bzip2, that is really weird. I use it from tar and I don't remember to have installed any additional package.
I'll check from my side. Thx for the info
 
john9527,

I have looked at the script nvram-save.sh and didn't see the call to the user script nvram-user.sh

From my side I have added this to make it working:
if [ -f nvram-user.sh ]; then
echo ""
echo "Launch the user script: nvram-user.sh"
echo ""

./nvram-user.sh "$rundate_RT-AC56U_3.0.0.4_378.50_beta2_dpi_nvram-jffs.tar.bz2"
fi

I just need to modify it to get back dynamically the firmware version.
Hope this helps.
 
john9527,

I have looked at the script nvram-save.sh and didn't see the call to the user script nvram-user.sh

From my side I have added this to make it working:


I just need to modify it to get back dynamically the firmware version.
Hope this helps.

Are you sure you updated to r12? It's right at the end of the file...

Code:
# Process user exit if it exists
if [ -f "./nvram-user.sh" ]; then
	./nvram-user.sh $dash$rundate$dash$macid
	echo "Complete: Processed user exit script "$fdir"/nvram-user.sh"
	echo ""

	fi

exit 0
 
Are you sure you updated to r12? It's right at the end of the file...

Code:
# Process user exit if it exists
if [ -f "./nvram-user.sh" ]; then
	./nvram-user.sh $dash$rundate$dash$macid
	echo "Complete: Processed user exit script "$fdir"/nvram-user.sh"
	echo ""

	fi

exit 0

For v13, any chance you could consider using logger rather than echo for the major 'in progress' messages?

Code:
logger -s -t "Started: Running in Backup Mode"
#echo "Running in Backup Mode"

I use WinSCP extensively, so rarely run scripts from a SSH comand line - I simply right click the script file and click execute - so I then have a record in syslog of the outcome of the script which is really useful when scheduled via cron.

Regards,
 
Hmm you are right, my mistake ... I was using the r11 :eek:
Apologies, Thx!

I have created a quick user script to backup either with bzip2 or zip

# User exit nvram-user.sh

# Variables declarations
rundate=$(date +%Y%m%d%H%M)
devicename=$(nvram get wps_device_name)
firmver=$(nvram get firmver)
buildno=$(nvram get buildno)
extendno=$(nvram get extendno)

echo ""
echo "Create the archive ..."
echo ""

# Check if bzip2 exists otherwize use zip
if type bzip2 >/dev/null; then
archive="$rundate"_"$devicename"_"$firmver"_"$buildno"_"$extendno"_nvram-jffs.tar.bz2
tar -jcvf $archive nvram* jffs* original*
else
archive="$rundate"_"$devicename"_"$firmver"_"$buildno"_"$extendno"_nvram-jffs.tar.gz
tar -zcvf $archive nvram* jffs* original*
fi

exit 0
 
For v13, any chance you could consider using logger rather than echo for the major 'in progress' messages?

Code:
logger -s -t "Started: Running in Backup Mode"
#echo "Running in Backup Mode"

I use WinSCP extensively, so rarely run scripts from a SSH comand line - I simply right click the script file and click execute - so I then have a record in syslog of the outcome of the script which is really useful when scheduled via cron.

Regards,

I didn't write to syslog by design to avoid cluttering it up, but would be willing to reconsider :), especially for just the major status msgs. I'll also do the same for the restore.

BTW, the next version already builds and puts a codelevel out in both the save and restore. I'll pass that to the user script as well for r14 (I never put out a release 13, superstitious :)
 
I wonder if you might consider special handling of the dhcp static list to reorder it in IP order. There is a sort instruction in the wiki to do this. I cut and paste the script output to do this.
 
I wonder if you might consider special handling of the dhcp static list to reorder it in IP order. There is a sort instruction in the wiki to do this. I cut and paste the script output to do this.

Let me think about that one.....you can do it in the code specific handling script or maybe the user exit script.
I'll see if I can come up with a good way to implement it.
 
Last edited:
Let me think about that one.....you can do it in the code specific handling script or maybe the user exit script.
I'll see if I can come up with a good way to implement it.

It will be nice to have such feature. Similar sorting by IP may be good for 'port forwarding' section, too.
 
Last edited:
Regarding bzip2, that is really weird. I use it from tar and I don't remember to have installed any additional package.
I'll check from my side. Thx for the info

I believe bzip2 is in /opt/bin. Not in the standard build. Did you by chance install Download Master in order to get the ipkg packages?
Do an "ls /opt/bin". If you see some executable's, you likely installed Download Master at some point.
 
You're right, bzip2 is in /opt/bin/bzip2
It should come from a previous installation I did of Download Master.
Thx!
 
I gathering we can't use this to save settings and restore them when going from 376.49_5 to 378.50?

See the first post of the 378.50 release thread.
 
New version available!

User NVRAM Save/Restore Utility

Version 14 7-February-2015
  • add version info to save/restore scripts
  • escape back-quote and double-quote characters
  • change handling of embedded lf chars
  • add short delay after commit before exiting script
  • changed name of inifile to indicate code family supported
  • changed name of exception script to indicate code family supported
  • pass codelevel to nvram-user.sh
  • log results of save and restore scripts to syslog
  • added exception rules for move to 378 code levels (jffs and VPN server)

Full Changelog is available in download directory
nvram-save-r14.zip
http://1drv.ms/16pENHc

Some quick update notes:
  • Some files have changed names
    nvram.ini has been renamed to nvram-merlin.ini
    nvram-exception.sh has been renamed to nvram-excp-merlin.sh
    The utility is still valid for ASUS OEM code as well as Merlin releases
  • The restore process will make the following changes if moving from a 376 or earlier code to 378
    • A single consolidated MAC filter list will be made from the 2.4 and 5 GHz lists
    • If jffs is not active, it will be set to be activated and formatted, jffs scripting will be disabled
    • If jffs is active, jffs scripting will also be activated
    • If you are using a VPN server, the settings will be migrated to the new nvram variable
-----------------------------------------------------------------




In addition, status msgs are now also printed to the router syslog.

Feb 5 13:25:10 nvram_save: NVRAM User Save Utility - Version 14 (nvram-merlin.ini)
Feb 5 13:25:10 nvram_save: Saving settings from firmware 374.43_2-07j9527
Feb 5 13:25:10 nvram_save: Running in Backup Mode
Feb 5 13:26:01 nvram_save: Complete: User NVRAM saved to ./nvram-restore-20150205-E1F2.sh
Feb 5 13:26:01 nvram_save: Complete: JFFS directory saved to /mnt/ASUS/jffs-20150205-E1F2
Feb 5 13:26:05 nvram_save: Complete: Processed user exit script ./nvram-user.sh
...

Feb 5 13:29:32 nvram-restore: NVRAM User Restore Utility - Version 14 (nvram-merlin.ini)
Feb 5 13:29:32 nvram-restore: Restoring settings from firmware 374.43_2-07j9527 20150205-E1F2
Feb 5 13:29:34 nvram-restore: Applying code level exceptions ./nvram-excp-merlin.sh
Feb 5 13:29:40 nvram-restore: Complete: User NVRAM restored
...

Feb 5 13:33:34 jffs_restore: JFFS Restore Utility - Version 14
Feb 5 13:33:34 jffs_restore: Restoring /jffs directory: jffs-20150205-E1F2
Feb 5 13:33:39 jffs_restore: /jffs restored from /mnt/ASUS/jffs-20150205-E1F2


Enjoy!
 
Last edited:
Does adding "merlin" (in v14) to the filenames mean the script will no longer work for the stock ASUS firmware?
 
Does adding "merlin" (in v14) to the filenames mean the script will no longer work for the stock ASUS firmware?

No....still OK for ASUS OEM.
I've added a note on this to the header and announce post. Thanks.

(the name change is prep for maybe something else happening in the future :) )
 
Last edited:
Status
Not open for further replies.

Latest threads

Sign Up For SNBForums Daily Digest

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