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 ... 9, 10, 11 ... 20, 21, 22  Next
Author Message
hardwarewizard
DD-WRT User


Joined: 15 Apr 2007
Posts: 200
Location: Buffalo, NY

PostPosted: Sun Jul 26, 2009 17:20    Post subject: Reply with quote
DHC_DarkShadow wrote:
At the very least shouldn't this be added to the Wiki under useful scripts?


possibly but lets wait til i get all the comments fixed and i am working on simple directions to use said script i just have to cut and paste most of it from this thread.
Sponsor
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Sun Jul 26, 2009 17:39    Post subject: Reply with quote
I wonder if there is a way to add other storage options? Some use USB, Others use SAMBA or CFFS. I personally use JFFS as I have a MMC mod.
_________________
The New Me
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jul 26, 2009 18:13    Post subject: Reply with quote
All these types of storage can be mounted to /opt
_________________
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)
DHC_DarkShadow
DD-WRT Guru


Joined: 22 Jun 2008
Posts: 2440
Location: Am now Dark_Shadow

PostPosted: Sun Jul 26, 2009 18:27    Post subject: Reply with quote
So do i use the same command to mount /opt to /mmc as I did /jffs?
_________________
The New Me
crashfly
DD-WRT Guru


Joined: 24 Feb 2009
Posts: 2003
Location: Sol System > Earth > USA > Arkansas

PostPosted: Sun Jul 26, 2009 18:40    Post subject: Reply with quote
Thank you frater for making your latest script "multi-user' friendly. I will implement this new script into my routine and hopefully, it should restore the settings a 'little' more faithfully.

As a side note, would it be better to put the wl_* variables into the "vars_to_skip" file for those routers with dual bands? (As per Ekos comments.)

Eko wrote:
wl_ are more or less obsolete, and were used for GUI, wl0_ and wl1_ are used for driver. Due to different radio caps in different routers NEVER use and wl_ or wl0_ or wl1_ in your "backup".... Also diff routers use diff interfaces for wan, lan...

Backup from one router is simply NOT compatible to use on another make/model. It might work, but you're playing with fire.

_________________
E3000 22200M KongVPN K26
WRT600n v1.1 refirb mega 18767 BS K24 NEWD2 [not used]
WRT54G v2 16214 BS K24 [access point]

Try Dropbox for syncing files - get 2.5gb online for free by signing up.

Read! Peacock thread
*PLEASE* upgrade PAST v24SP1 or no support.
hardwarewizard
DD-WRT User


Joined: 15 Apr 2007
Posts: 200
Location: Buffalo, NY

PostPosted: Sun Jul 26, 2009 19:08    Post subject: Reply with quote
[#########################################################
#FTP Login information change to your info
#########################################################
FTPS=ftp://192.168.10.210/backups
USERPASS=user:pass
[/quote]

do we need to have these lines in the script??

if i am understanding it right the ftp option is only available from the command line.

with a slight mod we could have a default login in the script using just the transfer option.
crashfly
DD-WRT Guru


Joined: 24 Feb 2009
Posts: 2003
Location: Sol System > Earth > USA > Arkansas

PostPosted: Sun Jul 26, 2009 19:18    Post subject: Reply with quote
Those lines are not required to be there.
However if they *are* there, then all you have to do is use the option "-t" which will use those lines specified in the script. The "-t" option does turn on the transfer capabilities of the script.

Edit: I am under the assumption that this script could be run from a cron job with the options applied.

_________________
E3000 22200M KongVPN K26
WRT600n v1.1 refirb mega 18767 BS K24 NEWD2 [not used]
WRT54G v2 16214 BS K24 [access point]

Try Dropbox for syncing files - get 2.5gb online for free by signing up.

Read! Peacock thread
*PLEASE* upgrade PAST v24SP1 or no support.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jul 26, 2009 19:46    Post subject: Reply with quote
These lines are there as default values...
If you just give "-t" the files are transferred using these values...

_________________
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)
hardwarewizard
DD-WRT User


Joined: 15 Apr 2007
Posts: 200
Location: Buffalo, NY

PostPosted: Sun Jul 26, 2009 19:50    Post subject: Reply with quote
frater wrote:
These lines are there as default values...
If you just give "-t" the files are transferred using these values...


thanks i needed to confirm what i thought was going on
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jul 26, 2009 19:53    Post subject: Reply with quote
crashfly wrote:
As a side note, would it be better to put the wl_* variables into the "vars_to_skip" file for those routers with dual bands? (As per Ekos comments.)

Yes, I think that's wise although you misunderstood it's for dual band routers. They are "legacy variables" from the v23 firmwares. v24 introduced multiple virtual wireless interfaces.

_________________
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)
hardwarewizard
DD-WRT User


Joined: 15 Apr 2007
Posts: 200
Location: Buffalo, NY

PostPosted: Sun Jul 26, 2009 20:54    Post subject: Reply with quote
Code:
#!/bin/sh
#########################################################
#   Script Requirements
#
#   Files:
#      vars_to_skip
#      vars_preferred
#
#   Programs:
#      curl
#########################################################

#########################################################
# setup variables
#
# DATE         - Date
# MAC         - Mac address
# FILE         - File Name Prefix
# CUR_DIR      - Current Directory
# transfer      - FTP Transfer ON/OFF (Default is OFF)
# FOLDER      - Location where backup scripts are stored
# VARFILE      - Location & Name of Temp File
# TO_ALL      - Location & Name of script File with all nvram variables
# TO_INCLUDE   - Location & Name of script File with essential nvram variables
# TO_EXCLUDE   - Location & Name of script File with dangerous nvram variables
# TO_PREFERRED   - Location & Name of script File with preferred nvram variables
#
#########################################################

DATE=`date +%m%d%Y`
MAC=`nvram get lan_hwaddr | tr -d ":"`
FILE=${MAC}.${DATE}
CUR_DIR=`dirname $0`
transfer=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
TO_PREFERRED=${FOLDER}/${MAC}.${DATE}.preferred.sh

#########################################################
#FTP Login information change to your info
#########################################################
 
FTPS=ftp://192.168.1.100/backups
USERPASS=user:pass

#########################################################
# read command line switches
#
#   example command lines
#
#   ./backupvars.sh -t
#
#   The above command with use the user and password and
#   server information embedded in this script.
#   (See FTP Login information above)
#
#
#   ./backupvars.sh -t -u user:pass -f ftp://192.168.1.100/backups
#
#   The above command with use the user and password and
#   server information from the command line
#
#########################################################

while getopts tu:f: name
do
  case $name in
  t)   transfer=1;;
  u)   USERPASS="$OPTARG";;
  f)   FTPS="$OPTARG";;
  ?)   printf "Usage: %s: [-t] [-u username:password] [-f ftpserver]\n" $0
       exit 2;;
  esac
done
shift $(($OPTIND - 1))

#########################################################
#create NVRAM variale list and write to /opt/tmp/all_vars
#########################################################

nvram show 2>/dev/null | egrep '^[A-Za-z][A-Za-z0-9_\.\-]*=' | awk -F = '{print $1}' | sort -r -u >${VARFILE}

#########################################################
# Write header to restore scripts
#########################################################

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

#########################################################
# scan NVRAM variable list and send variable to proper
# restore script
#########################################################

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

  # get the data out of the variable
  data=`nvram get ${var}`
  # 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 -e 's/[$`"\]/\\&/g' | tee -ia  ${TO_ALL} >> ${bfile}
  echo -e "\"" | tee -ia  ${TO_ALL} >> ${bfile}
  if [ ! ${pref} == 0 ]; then
    echo -en "nvram set ${var}=\"" >> ${TO_PREFERRED}
    echo -n "${data}" |  sed -e 's/[$`"\]/\\&/g' >> ${TO_PREFERRED}
    echo -e "\"" >> ${TO_PREFERRED}
  fi
done

#########################################################
# cleanup remove /opt/tmp/all_vars
# uncomment to remove file
#########################################################

# rm ${VARFILE}

#########################################################
# Write footer to restore script
#########################################################

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

#########################################################
# Change permissions on restore scripts to make them
# executable
#########################################################

chmod +x ${TO_INCLUDE}
chmod +x ${TO_PREFERRED}
chmod +x ${TO_EXCLUDE}
chmod +x ${TO_ALL}

#########################################################
# Compress restore scripts and send them to ftp server
#########################################################

if [ ${transfer} -ne 0 ] ; then
  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_PREFERRED}" 2>/dev/null | gzip -c |  /opt/bin/curl -s -u ${USERPASS} "${FTPS}/${FILE}.preferred.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 -
fi


this is an updated version and attached the files as well added the exclude wl_ variables.

let me know whats wrong or what i should add



dd-wrt backup files.zip
 Description:

Download
 Filename:  dd-wrt backup files.zip
 Filesize:  2.47 KB
 Downloaded:  601 Time(s)

hardwarewizard
DD-WRT User


Joined: 15 Apr 2007
Posts: 200
Location: Buffalo, NY

PostPosted: Sun Jul 26, 2009 21:12    Post subject: Reply with quote
is there a how to to install curl someplace??
crashfly
DD-WRT Guru


Joined: 24 Feb 2009
Posts: 2003
Location: Sol System > Earth > USA > Arkansas

PostPosted: Sun Jul 26, 2009 21:32    Post subject: Reply with quote
frater wrote:
Yes, I think that's wise although you misunderstood it's for dual band routers. They are "legacy variables" from the v23 firmwares. v24 introduced multiple virtual wireless interfaces.

I did not know if those were legacy variables or not. However, your statement introduces clear understanding now.

Edit: You might want to make a disclaimer on your first post (or at least show Eko's comments) so people do not make the wrong assumptions in using your backup script for different routers.

_________________
E3000 22200M KongVPN K26
WRT600n v1.1 refirb mega 18767 BS K24 NEWD2 [not used]
WRT54G v2 16214 BS K24 [access point]

Try Dropbox for syncing files - get 2.5gb online for free by signing up.

Read! Peacock thread
*PLEASE* upgrade PAST v24SP1 or no support.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Jul 26, 2009 21:40    Post subject: Reply with quote
hardwarewizard wrote:
is there a how to to install curl someplace??

Just
Code:
ipkg-opt install libcurl

You need to have optware installed of course.

_________________
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)
hardwarewizard
DD-WRT User


Joined: 15 Apr 2007
Posts: 200
Location: Buffalo, NY

PostPosted: Sun Jul 26, 2009 21:56    Post subject: Reply with quote
frater wrote:
You need to have optware installed of course.


is optware as simple to install ?? I'm reading the wiki now:)



ok wiki is confusing as all heck to install optware.


Last edited by hardwarewizard on Mon Jul 27, 2009 21:00; edited 1 time in total
Goto page Previous  1, 2, 3 ... 9, 10, 11 ... 20, 21, 22  Next Display posts from previous:    Page 10 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