[Release] NVRAM Save/Restore Utility

Xentrk

Part of the Furniture
Maybe this is because I saved and restored on the latest (384.18) Merlin, but when I did so, everything seemed to be OK, with a few exceptions:
- the custom traffic stats location was lost and went to the default ram location
- custom scripts were disabled even though I had them enabled prior to save/factory-reset/restore.
(RT-AC68U)
The jffs custom scripts has to be manually configured after a factory reset and before running the utility. I thought I had mentioned this in the README but it doesn't look like it. I will add it to the documentation. I'll look into the custom traffic stats location. I don't use that feature so it wasn't something I noticed an issue with during my testing.
 

ttgapers

Senior Member
Here is the systembackup.sh script I use. I amended from this forum when this script was manual. @Xentrk I haven't used your installer - but used your updates due to this. So here it is for the community's use and perhaps amended to your release!!

Code:
#!/bin/sh

UTIL=nvram
BLOC=/mnt/<usb-label>/$UTIL
BARC=$BLOC/archive
BKUP=$BLOC/backup
RETENTION=7

CRUNAME=$UTIL
cru l | grep $CRUNAME >/dev/null || cru a $CRUNAME "0 5 * * * $0 $*"

#exit if directory doesn't exist or not mounted.
[[ -d "$BLOC" ]] || exit 1
[[ -d "$BKUP" ]] && rm -rf $BKUP
[[ -d "$BKUP" ]] || mkdir $BKUP
cd "$BLOC"

/mnt/<usb-label>/nvram/nvram-save.sh -clk -b
#mv "$BKUP" "$BKUP.$(date +"%F_%T")"
sleep 30
mv "$BKUP" "$BKUP.$(hostname).$(date +%Y%m%d%H%M)"
mv "$BKUP.$(hostname).$(date +%Y%m%d%H%M)" "$BARC"


#careful here.  You do not want this running if ntp hasn't synced.
find $BARC -name "backup.$(hostname).20*" -mtime +$RETENTION -exec rm -rf {} \;


exit 0
It needs definition of the variables for
UTIL - name of your scripts folder
BLOC - backup location
BARC=Archive folder
BKUP= Backup folder (for current runs)
RETENTION= Retention period

I tie it together by having this in my service-start as the script above creates the scheduled task:

Code:
# Add NVRAM backup job & run retention
#/usr/sbin/cru a Backup "0 5 * * * /tmp/mnt/sauron-usb/nvram/nvram-save.sh"
/jffs/scripts/systembackup.sh
Hope you find it useful....I think it was in the original nvram thread...

I've tweaked and published the script here: https://github.com/ttgapers/backup-merlin

Anyone care/want to use it, please be my guest!
 

Xentrk

Part of the Furniture

Xentrk

Part of the Furniture
nvram-save.sh patch available - 11 July 2020

nvram-save.sh has been patched to fix issue reported by @ech


To exclude an nvram setting from being saved during a migration save, or restored during a migration restore, prefix it with a @ in nvram-merlin.ini. The code was not processing these variables for a normal backup save/restore.

Following are the variables in the nvram-merlin.ini file that were being skipped in error during backup save/restore.
@AllLED
@jffs2_enable
@jffs2_exec
@jffs2_format
@jffs2_on
@jffs2_scripts
@https_crt_cn
@https_crt_file
@https_crt_gen
@https_crt_save
@lan_hostname
@usb_usb2
@usb_usb3
@usb_idle_exclude
@usb_idle_timeout
@rstats_bak
@rstats_colors
@rstats_data
@rstats_enable
@rstats_exclude
@rstats_new
@rstats_offset
@rstats_path
@rstats_sshut
@rstats_stime
@cstats_all
@cstats_enable
@cstats_exclude
@cstats_include
@cstats_new
@cstats_sshut
@led_disable
@btn_ez
@btn_ez_mode
@btn_ez_radiotoggle
@btn_led
@btn_led_gpio
@btn_led_mode
@btn_lte
@btn_rst
@btn_wifi_sw
@btn_wifi_toggle
@gro_disable
@diskmon_force_stop
@diskmon_freq
@diskmon_freq_time
@diskmon_part
@diskmon_policy
@diskmon_status
@diskmon_usbport
@usb_path1_diskmon_freq
@usb_path1_diskmon_freq_time
@usb_path2_diskmon_freq
@usb_path2_diskmon_freq_time
@usb_path3_diskmon_freq
@usb_path3_diskmon_freq_time
@wl0_reg_mode
@wl0_txpower
@wl0_TxPower
@wl1_reg_mode
@wl1_txpower
@wl1_TxPower
@wl2_reg_mode
@wl2_txpower
@wl2_TxPower
@acs_band3
@acs_ch13
@daapd_friendly_name
@dms_friendly_name
@computer_name

Update:
Type nsrum on the command line to access the menu. Select option

[2] Check for updates to existing installation

to get the new version. Run nvram-save.sh to get a fresh backup.
 

visortgw

Senior Member
nvram-save.sh patch available - 11 July 2020

nvram-save.sh has been patched to fix issue reported by @ech


To exclude an nvram setting from being saved during a migration save, or restored during a migration restore, prefix it with a @ in nvram-merlin.ini. The code was not processing these variables for a normal backup save/restore.

Following are the variables in the nvram-merlin.ini file that were being skipped in error during backup save/restore.
@AllLED
@jffs2_enable
@jffs2_exec
@jffs2_format
@jffs2_on
@jffs2_scripts
@https_crt_cn
@https_crt_file
@https_crt_gen
@https_crt_save
@lan_hostname
@usb_usb2
@usb_usb3
@usb_idle_exclude
@usb_idle_timeout
@rstats_bak
@rstats_colors
@rstats_data
@rstats_enable
@rstats_exclude
@rstats_new
@rstats_offset
@rstats_path
@rstats_sshut
@rstats_stime
@cstats_all
@cstats_enable
@cstats_exclude
@cstats_include
@cstats_new
@cstats_sshut
@led_disable
@btn_ez
@btn_ez_mode
@btn_ez_radiotoggle
@btn_led
@btn_led_gpio
@btn_led_mode
@btn_lte
@btn_rst
@btn_wifi_sw
@btn_wifi_toggle
@gro_disable
@diskmon_force_stop
@diskmon_freq
@diskmon_freq_time
@diskmon_part
@diskmon_policy
@diskmon_status
@diskmon_usbport
@usb_path1_diskmon_freq
@usb_path1_diskmon_freq_time
@usb_path2_diskmon_freq
@usb_path2_diskmon_freq_time
@usb_path3_diskmon_freq
@usb_path3_diskmon_freq_time
@wl0_reg_mode
@wl0_txpower
@wl0_TxPower
@wl1_reg_mode
@wl1_txpower
@wl1_TxPower
@wl2_reg_mode
@wl2_txpower
@wl2_TxPower
@acs_band3
@acs_ch13
@daapd_friendly_name
@dms_friendly_name
@computer_name

Update:
Type nsrum on the command line to access the menu. Select option

[2] Check for updates to existing installation

to get the new version. Run nvram-save.sh to get a fresh backup.
Error during update:

chmod: /nvram-save.sh: No such file or directory​

Not sure that it breaks anything as the save script appears to update and run to completion.
 

Goran

Occasional Visitor
Hi,
I am getting following error:
cp: can't create '/tmp/mnt/ASUS/nsru/backup/jffs-202007111858_RT-AC88U-E768/./.sys/WBL/wlist_m/"MAC address"': Inval id or incomplete multibyte or wide character
cp: can't create '/tmp/mnt/ASUS/nsru/backup/jffs-202007111858_RT-AC88U-E768/./.sys/WBL/blist_m/"MAC address"': Inval id or incomplete multibyte or wide character

where "MAC address" is MAC address of my kid's phone.

Is backup performed well because of this error?

Thank you.
 

Xentrk

Part of the Furniture
Error during update:

chmod: /nvram-save.sh: No such file or directory​

Not sure that it breaks anything as the save script appears to update and run to completion.
Does this command show the correct install location of NVRAM Save/Restore Utility?
Code:
ls -d -- /tmp/mnt/*/nsru
Change to the NVRAM Save/Restore location and type this to confirm the updated file downloaded correctly:
Code:
cat nvram-save.sh | grep "Version 30.3.1"
 

Xentrk

Part of the Furniture
Hi,
I am getting following error:
cp: can't create '/tmp/mnt/ASUS/nsru/backup/jffs-202007111858_RT-AC88U-E768/./.sys/WBL/wlist_m/"MAC address"': Inval id or incomplete multibyte or wide character
cp: can't create '/tmp/mnt/ASUS/nsru/backup/jffs-202007111858_RT-AC88U-E768/./.sys/WBL/blist_m/"MAC address"': Inval id or incomplete multibyte or wide character

where "MAC address" is MAC address of my kid's phone.

Is backup performed well because of this error?

Thank you.
I suspect it may have to do with the format of the USB drive. Is it NTFS format?
Run the command:
Code:
fdisk -l
What is listed under the "System" column heading? If it's ext2,3 or 4 format, it should say "Linux". The code saves to disk differently if saving to NTFS. So that may be where the issue is.

The command mount will show the format type for all mount points.
 
Last edited:

JonEngland

Occasional Visitor
This is a difficult one to debug and find the root cause since there are no error messages. It just appears to stop writing to disk.

Have you run diagnostics on the attached storage? You can unmount the USB on the main page and run the Health Scanner to see if there are bad sectors. Or, manually run the 'e2fsck -p' command after unmounting the disk.
I was getting the same issue (I think it was since since upgrading to 384.18 but possibly a coincidence) and the point at which it hangs seems different each time. In example below I left it running for 30 mins but nothing happens and I saw no further log entries
upload_2020-7-13_19-34-9.png


disk check script shows output below
Running disk check v2.9, with command 'e2fsck -p' on /dev/sda1
SanDisk4GB: clean, 1868/244800 files, 340245/977408 blocks
Mon Jul 13 12:27:26 IST 2020 Disk check done on /dev/sda1

I then enabled USB 3.0 mode and plugged the usb stick in to the USB 3.0 port, re-ran the nvram-save script and it completed in no time at all, which was the first time it completed for me on this firmware version.
 
Last edited:

Xentrk

Part of the Furniture
I was getting the same issue (I think it was since since upgrading to 384.18 but possibly a coincidence) and the point at which it hangs seems different each time. In example below I left it running for 30 mins but nothing happens and I saw no further log entries
View attachment 24686

disk check script shows output below
Running disk check v2.9, with command 'e2fsck -p' on /dev/sda1
SanDisk4GB: clean, 1868/244800 files, 340245/977408 blocks
Mon Jul 13 12:27:26 IST 2020 Disk check done on /dev/sda1

I then enabled USB 3.0 mode and plugged the usb stick in to the USB 3.0 port, re-ran the nvram-save script and it completed in no time at all, which was the first time it completed for me on this firmware version.
Thanks for the information. Keep us updated.
 

brec

Occasional Visitor
What is the relation between this utility and the GUI's "Save setting" and "Backup JFFS partition" functions? If I wanted to have an ability to clone my router in case my pet elephant steps on it, how would these two compare? I guess it's an issue of what nvram items are saved by "Save setting"?
 

Xentrk

Part of the Furniture
What is the relation between this utility and the GUI's "Save setting" and "Backup JFFS partition" functions? If I wanted to have an ability to clone my router in case my pet elephant steps on it, how would these two compare? I guess it's an issue of what nvram items are saved by "Save setting"?
Either utility will work for the situation you describe. The NVRAM Save/Restore Utility does not backup the router password since it is encrypted and not really required. Other than that, it is supposed to save all of the necessary nvram vars so you can recover from a disaster. Some people schedule cron jobs to run the NVRAM Save/Restore Utility. The firmware backup writes to your PC while the utility writes to USB disk.
 

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