Backup settings and restore them to even different hardware.

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Goto page Previous  1, 2, 3, 4 ... 20, 21, 22  Next
Author Message
gene
DD-WRT Guru


Joined: 28 Dec 2007
Posts: 599

PostPosted: Sun Mar 08, 2009 23:23    Post subject: Reply with quote
yes, but it does not say you need to run ALL 3 .sh files, and that is what I'm trying to clear up...the instructions says to run only one of them by name to preform a restore. So all 3 must be run to do a full retore ?
_________________
WRT160N v3, wrt54G v2(BCM4712 chip rev 1, corerev=7) A/P WDS WPA2 Personal Aes, DD-WRT usually the most current BS builds and less frequently lately EKO builds(because of new BS rules that eliminated EKO builds I used).
Sponsor
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Mon Mar 09, 2009 0:19    Post subject: Reply with quote
No....

You can run the essential, which should be enough.
The rest is for completeness and debugging purposes...

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
gene
DD-WRT Guru


Joined: 28 Dec 2007
Posts: 599

PostPosted: Mon Mar 09, 2009 0:44    Post subject: Reply with quote
thanks frater...
_________________
WRT160N v3, wrt54G v2(BCM4712 chip rev 1, corerev=7) A/P WDS WPA2 Personal Aes, DD-WRT usually the most current BS builds and less frequently lately EKO builds(because of new BS rules that eliminated EKO builds I used).
veekay
DD-WRT Novice


Joined: 09 Mar 2009
Posts: 1

PostPosted: Mon Mar 09, 2009 6:51    Post subject: Reply with quote
Just wanted to say thank you to both frater and dellsweig - I used to spend a ton of time saving PDF's of all my settings and redoing everything manually - now I can actually try out different builds without spending an hour or two each time with my settings.
tcharron
DD-WRT User


Joined: 12 Aug 2007
Posts: 112

PostPosted: Mon Mar 30, 2009 19:15    Post subject: Reply with quote
When I run this script, everything ends up in both the all.sh script and the dangerous script, but my essential.sh file has nothing relevant in it.
It looks to me that this line is the problem:
Code:
f echo ${var} | grep -q -f "${CUR_DIR}/vars_to_skip" ; then

Doesn't the -q parameter cause nothing to be output? Or is grep supposed to send a return code back to the shell?
When I run this manually, it works fine (ie: it looks like my vars_to_skip file is being found and has the right eol delimiter).
Nighthawk Foo
DD-WRT Novice


Joined: 30 Mar 2009
Posts: 2

PostPosted: Mon Mar 30, 2009 20:09    Post subject: Reply with quote
This is a very handy script...it should be a sticky post.
smurphster
DD-WRT Novice


Joined: 03 Apr 2008
Posts: 15
Location: Oshkosh, WI

PostPosted: Fri Apr 03, 2009 20:11    Post subject: Reply with quote
tcharron wrote:
When I run this script, everything ends up in both the all.sh script and the dangerous script, but my essential.sh file has nothing relevant in it.
It looks to me that this line is the problem:
Code:
f echo ${var} | grep -q -f "${CUR_DIR}/vars_to_skip" ; then

Doesn't the -q parameter cause nothing to be output? Or is grep supposed to send a return code back to the shell?
When I run this manually, it works fine (ie: it looks like my vars_to_skip file is being found and has the right eol delimiter).


i'm seeing the same problem. i'll play around with it and see if i can fix it. my bash scripting skills are a bit rusty though :D


EDIT:

found the problem. change that line to:
Code:
if cat ${CUR_DIR}/vars_to_skip | grep -q ${var} ; then


not sure why the original line doesn't work but that change worked for me. grep seems to have some different options than i'm used to (ubuntu). also it helps to put a # in front of the !/bin/sh

EDIT: bad advice... ignore this post!

_________________
WRT54GL 1.1 V24-preSP2 VPN
WAPBR-100 V24-preSP2 micro


Last edited by smurphster on Tue Apr 07, 2009 1:08; edited 1 time in total
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Apr 05, 2009 10:24    Post subject: Reply with quote
smurphster wrote:

found the problem. change that line to:
Code:
if cat ${CUR_DIR}/vars_to_skip | grep -q ${var} ; then


not sure why the original line doesn't work but that change worked for me. grep seems to have some different options than i'm used to (ubuntu). also it helps to put a # in front of the !/bin/sh


That # is only missing from Dellsweigs 'copy'.
I can't explain why that one line was nog working for you...

The change you did is doing the same as was intended. I don't know why the original wasn't working for you.

EDIT: The above is not true.. It seems to be the same, but it isn't. See my post below!!!!!

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)


Last edited by frater on Tue Apr 07, 2009 5:50; edited 3 times in total
tcharron
DD-WRT User


Joined: 12 Aug 2007
Posts: 112

PostPosted: Sun Apr 05, 2009 21:25    Post subject: Reply with quote
Actually, with the suggested change, it seems that all of the variables marked ^ are excluded, and those variables end up in the essential.sh script as a result.
I manually edited them out, but found that after running essential, some settings that should have been excluded were not. I tried migrating settings from a wrtsl54gs to a dell truemobile 2300, and dd-wrt identified itself as a wrtsl54gs (before rebooting). After rebooting, it was bricked.
gene
DD-WRT Guru


Joined: 28 Dec 2007
Posts: 599

PostPosted: Mon Apr 06, 2009 11:47    Post subject: Reply with quote
smurphster wrote:
tcharron wrote:
When I run this script, everything ends up in both the all.sh script and the dangerous script, but my essential.sh file has nothing relevant in it.
It looks to me that this line is the problem:
Code:
f echo ${var} | grep -q -f "${CUR_DIR}/vars_to_skip" ; then

Doesn't the -q parameter cause nothing to be output? Or is grep supposed to send a return code back to the shell?
When I run this manually, it works fine (ie: it looks like my vars_to_skip file is being found and has the right eol delimiter).


i'm seeing the same problem. i'll play around with it and see if i can fix it. my bash scripting skills are a bit rusty though :D


EDIT:

found the problem. change that line to:
Code:
if cat ${CUR_DIR}/vars_to_skip | grep -q ${var} ; then


not sure why the original line doesn't work but that change worked for me. grep seems to have some different options than i'm used to (ubuntu). also it helps to put a # in front of the !/bin/sh
When I run this script: .all.sh and .essential.sh have the exact same contents in them, and dangerous.sh has nothing relevant in it. It seems odd to have the same script produce the same error in different output files to me. are we sure the script is outputting the correct variables in the restore scripts ?!?!
_________________
WRT160N v3, wrt54G v2(BCM4712 chip rev 1, corerev=7) A/P WDS WPA2 Personal Aes, DD-WRT usually the most current BS builds and less frequently lately EKO builds(because of new BS rules that eliminated EKO builds I used).
tcharron
DD-WRT User


Joined: 12 Aug 2007
Posts: 112

PostPosted: Mon Apr 06, 2009 11:51    Post subject: Reply with quote
The modified version isn't filtering everything it should. I can' trestore using it. (I can't speak for the original, as it didn't work for me).
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Mon Apr 06, 2009 19:39    Post subject: Reply with quote
On 2nd thought...
It should really be:
Code:
if echo ${var} | grep -q -f "${CUR_DIR}/vars_to_skip" ; then


Because the contents of the file is used as an argument and then the ^ has a meaning as a valid expression (^ means the string has to start with...)

At first glance your line seemed to make sense, but it isn't doing what I intended at the time. Because I wrote the script a while ago I too thought it was the same.

I still don't know why the script isn't working for you. Mine gives me a config-file every night:
Code:
-rwxr-xr-x    1 root     root        40838 Apr  5 04:07 0018F398DEC1.04052009.essential.sh
-rwxr-xr-x    1 root     root         5519 Apr  5 04:07 0018F398DEC1.04052009.dangerous.sh
-rwxr-xr-x    1 root     root        46257 Apr  5 04:07 0018F398DEC1.04052009.all.sh
drwxr-xr-x    3 root     root        12288 Apr  6 04:04 .
-rwxr-xr-x    1 root     root        40973 Apr  6 04:07 0018F398DEC1.04062009.essential.sh
-rwxr-xr-x    1 root     root         5519 Apr  6 04:07 0018F398DEC1.04062009.dangerous.sh
-rwxr-xr-x    1 root     root        46392 Apr  6 04:07 0018F398DEC1.04062009.all.sh


This is the script which runs every night on my router...

cat /opt/usr/sbin/backupessential
Code:
#!/bin/sh
#
# This shell script creates a shell file with lines of the form
# nvram set x=y
# for every nvram variable found from
# nvram show
#
DATE=`date +%m%d%Y`
MAC=`nvram get lan_hwaddr | tr -d ":"`
FILE=${MAC}.${DATE}
CUR_DIR=`dirname $0`
FOLDER=/opt/var/backups
VARFILE=/opt/tmp/all_vars
TO_ALL=${FOLDER}/${MAC}.${DATE}.all.sh
TO_INCLUDE=${FOLDER}/${MAC}.${DATE}.essential.sh
TO_EXCLUDE=${FOLDER}/${MAC}.${DATE}.dangerous.sh
FTPS=ftp://192.168.10.210/backups
USERPASS=user:password

nvram show 2>/dev/null | egrep '^[a-zA-Z].*=' | awk -F= '{print $1}' | grep -v "[ /+<>,:;]" | sort -u >${VARFILE}

#
echo -e "#!/bin/sh\n#\necho \"Write variables\"\n" | tee -i ${TO_EXCLUDE} | tee -i  ${TO_ALL} > ${TO_INCLUDE}

cat ${VARFILE} | while read var
do
  if echo ${var} | grep -q -f "${CUR_DIR}/vars_to_skip" ; then
    bfile=$TO_EXCLUDE
  else
    bfile=$TO_INCLUDE
  fi

  # get the data out of the variable
  data=`nvram get ${var}`
  if [ "${data}" == "" ] ; then
    echo -e "nvram set ${var}="  | tee -ia  ${TO_ALL} >> ${bfile}
  else
    # write the var to the file and use \ for special chars: (\$`")
    echo -en "nvram set ${var}=\"" | tee -ia ${TO_ALL} >> ${bfile}
    echo -n "${data}" | sed 's/\\/\\\\/g' | sed 's/`/\\`/g' | sed 's/\$/\\\$/g' | sed 's/\"/\\"/g' | tee -ia  ${TO_ALL} >> ${bfile}
    echo -e "\"" | tee -ia  ${TO_ALL} >> ${bfile}
  fi

done

# rm ${VARFILE}

echo -e "\n# Commit variables\necho \"Save variables to nvram\"\nnvram commit"  | tee -ia  ${TO_ALL} | tee -ia  ${TO_EXCLUDE} >> ${TO_INCLUDE}
chmod +x ${TO_ALL}
chmod +x ${TO_INCLUDE}
chmod +x ${TO_EXCLUDE}

tar cpf - -C / "${TO_INCLUDE}" 2>/dev/null | gzip -c |  /opt/bin/curl -s -u ${USERPASS} "${FTPS}/${FILE}.essential.sh.tgz" -T -
tar cpf - -C / "${TO_EXCLUDE}" 2>/dev/null | gzip -c |  /opt/bin/curl -s -u ${USERPASS} "${FTPS}/${FILE}.dangerous.sh.tgz" -T -
tar cpf - -C / "${TO_ALL}" 2>/dev/null | gzip -c |  /opt/bin/curl -s -u ${USERPASS} "${FTPS}/${FILE}.all.sh.tgz" -T -

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
tcharron
DD-WRT User


Joined: 12 Aug 2007
Posts: 112

PostPosted: Mon Apr 06, 2009 20:21    Post subject: Reply with quote
I was able to answer my own question:
Code:
root@AEnet:/tmp# echo sshd_dss_host_key | grep -f /tmp/vars_to_skip
root@AEnet:/tmp# echo "sshd_dss_host_key " | grep -f /tmp/vars_to_skip
sshd_dss_host_key
root@AEnet:/tmp#


I think that when I cut and paste the vars_to_skip file into my editor from the dd-wrt site, it picked up trailing spaces on each line. Once I deleted them, it worked ok.
smurphster
DD-WRT Novice


Joined: 03 Apr 2008
Posts: 15
Location: Oshkosh, WI

PostPosted: Mon Apr 06, 2009 21:07    Post subject: Reply with quote
frater: thanks for following up. i had a feeling you used that syntax to avoid some glitch. piping the file to grep just seemed too easy Smile. i'll keep messing with it and see what i find.

one other thing i noticed though is...
Code:
CUR_DIR=`dirname $0`

returns "."

obviously the current directory is ".", it always is! but assuming the script is actually executing in /tmp, that should be fine. that may only be an issue in dellsweig's script. i'll take a look tonight.

_________________
WRT54GL 1.1 V24-preSP2 VPN
WAPBR-100 V24-preSP2 micro
tcharron
DD-WRT User


Joined: 12 Aug 2007
Posts: 112

PostPosted: Tue Apr 07, 2009 1:02    Post subject: Reply with quote
I found that I had to add a few variables to the vars_to_skip to allow migrating settings from a wrtsl54gs to my Dell TrueMobile 2300:

clkfreq
il0macaddr
all jffs settings (I had no space on the dell)
^ip_conntrack
pa0b0
pa0b1
pa0b2
pa0itssit
sromrev

Maybe I didn't need all of these, but I was bricking each time I tried, then removed all of these and it worked.
Goto page Previous  1, 2, 3, 4 ... 20, 21, 22  Next Display posts from previous:    Page 3 of 22
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware 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