Joined: 15 Apr 2007 Posts: 200 Location: Buffalo, NY
Posted: Sun Jul 26, 2009 17:20 Post subject:
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.
Joined: 22 Jun 2008 Posts: 2440 Location: Am now Dark_Shadow
Posted: Sun Jul 26, 2009 17:39 Post subject:
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
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
Joined: 24 Feb 2009 Posts: 2026 Location: Sol System > Earth > USA > Arkansas
Posted: Sun Jul 26, 2009 18:40 Post subject:
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.
Joined: 15 Apr 2007 Posts: 200 Location: Buffalo, NY
Posted: Sun Jul 26, 2009 19:08 Post subject:
[#########################################################
#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.
Joined: 24 Feb 2009 Posts: 2026 Location: Sol System > Earth > USA > Arkansas
Posted: Sun Jul 26, 2009 19:18 Post subject:
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.
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
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
#########################################################
# 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
#
#########################################################
#########################################################
#FTP Login information change to your info
#########################################################
#########################################################
# 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
#########################################################
#########################################################
# 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
#########################################################
# 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
#########################################################
#########################################################
# Compress restore scripts and send them to ftp server
#########################################################
Joined: 24 Feb 2009 Posts: 2026 Location: Sol System > Earth > USA > Arkansas
Posted: Sun Jul 26, 2009 21:32 Post subject:
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.
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