Log in

Bekijk de volledige versie : Full backup of NVRAM, settings, configuration



seff
19-09-2008, 09:37
Hi,

I was searching the forum to answer a simple question. How do I take and automate a full backup of my WL-500gx? It happened to my a few times, that I had a power outage and my system reverted back to the default flashed firmware (Oleg's 1.9.2.7-10). This means that all configuration settings using flashfs save were lost. Of course, my USB memory stick was intact.

Using the GUI, there are two steps to backup the device:

1. System Setup/Flashfs Management/Save As...
2. System Setup/Setting Management/Save As...

Using CLI, there should be two corresponding steps as well:

1. Run flashfs save and cp /tmp/flash.tar.gz /tmp/harddisk
2. Create and copy all settings. But how to create and I copy the settings as in GUI? Any idea? ;)

I would like to use cron and backup all my configuration to the USB memory stick once a week automatically...

Thank you,
Seff

seff
26-09-2008, 15:08
I figured it out myself. The configuration (that can be loaded back) is simply a list of lines in NVRAM with a header:

echo "HDR1 , " > /opt/backup/WL500g.Deluxe.CFG
nvram show >> /opt/backup/WL500g.Deluxe.CFG
flashfs save && flashfs commit
cp /tmp/flash.tar.gz /opt/backup/WL500g.Deluxe.tar.gz

Perphaps flashfs commit is not needed...
And lines should be separated by spaces... (I will work on it and post it here when finished)

:)
Seff

seff
12-03-2009, 09:47
I have made it as part of a weekly cron job script:



#!/bin/sh
# backup volatile data from router to the flash card

PATH=${prefix}/sbin:${prefix}/bin:/sbin:/bin:/usr/sbin:/usr/bin
BACKUP_PATH=/tmp/harddisk/data/backup

echo "HDR1 , " > $BACKUP_PATH/WL500g.Deluxe.CFG
nvram show >> $BACKUP_PATH/WL500g.Deluxe.CFG
gzip $BACKUP_PATH/WL500g.Deluxe.CFG
flashfs save
cp /tmp/flash.tar.gz $BACKUP_PATH

# atomic operations
mv $BACKUP_PATH/WL500g.Deluxe.CFG.gz $BACKUP_PATH/`date +%y%m%d`.WL500g.Deluxe.CFG.gz
mv $BACKUP_PATH/flash.tar.gz $BACKUP_PATH/`date +%y%m%d`.flash.tar.gz

wiz
12-03-2009, 11:11
just my curiosity. Why a weekly backup? Do you change settings regularly?

cheers,

Wiz

al37919
12-03-2009, 12:16
you can use undocumented

nvram save filename
nvram restore filename
this is the way how nvram is stored in web-interface. I think it is more safe way than your approach.

I'm using a bit different approach --- saving of 'nvram show' output and such nvram_restore script:


#! /bin/sh
cat /opt/tmp/save/fs/last/nvram.txt | awk -F'=' '{print "nvram set " $1 "='\''" $2 "'\''"}' | sh
nvram commit

seff
20-03-2009, 04:39
Lovely! :o

I will update my script with:



nvram save filename


I run weekly backups because I have peace of mind. My wl500gx was reset twice when I mistakenly unplugged the A/C adapter. It's probably a manufacturing defect with these older wl500g Deluxe devices. Comparing for changes in nvram is good too, I am too lazy to script it :)

al37919
22-04-2009, 08:11
For those, who would like to attempt to restore the configuration saved from the web interface, or by nvram restore, I'd recommend to take into account the following http://code.google.com/p/wl500g/issues/detail?id=20&colspec=ID%20Type%20Status%20Priority%20Owner%20Su mmary%20Opened

This issue equally affects users of Oleg's, lly's, and all known up to date asus firmwares (1.9.*, 2.0.0.6, 3.0.3.6).

My second solution from this post: http://wl500g.info/showpost.php?p=136554&postcount=5 works fine ;)