Backup settings and restore them to even different hardware.

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page Previous  1, 2, 3, ... 22, 23, 24  Next
Author Message
Slione
DD-WRT User


Joined: 05 Dec 2007
Posts: 215
Location: Michigan

PostPosted: Sun Feb 01, 2009 14:20    Post subject: Reply with quote
frater wrote:
Giving your questions I don't think you have the basic Linux skills to pull it off.


Bingo! This is where I am at. My question to you would be could you help us that do not have the Linux skills or point in in the right direction? Confused
Sponsor
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Feb 01, 2009 15:06    Post subject: Reply with quote
It sounded a bit condescending, but it wasn't meant that way at all....

It's just that I already know that if I explain one thing, you'll have even more questions and still have no results....

But anyhow...
I'll try.

Your router can run scripts written in bash. So-called shell scripts.
The script I wrote should be saved in the router together with the 2nd file called "vars_to_skip".
In Linux you can execute a script by giving it the "executable-flag" and enter its name with its path.
You can give a file an executable-flag by issuing the command.
Code:
chmod +x <filename>


The first pitfall for a windows user is to just give the name whilst you are in that same directory. It will NOT execute it. You have to precede it with ./

It will only execute it if you give the exact location or it's in its path. To see your path enter "echo $PATH"

I have a router with USB-support and attached a USB-stick to it with an ext3-partition which I mounted as /opt. This makes things a lot easier.
If you don't have USB-support, you can enable jffs-space, create the directory /jffs/opt and mount it as /opt.
Code:
mkdir /jffs/opt

Just put this line in your startup
Code:
mount -o bind /jffs/opt /opt

and reboot your router....

Then create these directories
Code:
mkdir -p /opt/usr/bin
mkdir -p /opt/usr/sbin
mkdir -p /opt/bin
mkdir -p /opt/sbin
mkdir -p /opt/var/backups

You will now have a proper framework to start working. Put the 2 files in /opt/usr/sbin and make them executable. You can do this with winSCP (google) after you enabled SSH and changed the preference in WinSCP to use SSH instead of SFTP.

Let me know how far you come this time....[/code]

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


Joined: 05 Dec 2007
Posts: 215
Location: Michigan

PostPosted: Sun Feb 01, 2009 15:57    Post subject: Reply with quote
frater wrote:
It sounded a bit condescending, but it wasn't meant that way at all....


I didn't take it that way at all. I can admit when I am beyond my limited capabilities but am always willing to learn. :)


Quote:
Let me know how far you come this time....


I will try this tomorrow and let you know the outcome. Thanks!
dellsweig
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 1476
Location: New York, USA

PostPosted: Sun Feb 01, 2009 16:34    Post subject: Reply with quote
Slione wrote:
frater wrote:
It sounded a bit condescending, but it wasn't meant that way at all....


I didn't take it that way at all. I can admit when I am beyond my limited capabilities but am always willing to learn. :)


Quote:
Let me know how far you come this time....


I will try this tomorrow and let you know the outcome. Thanks!


Frater

Can I make a suggestion here that might make this more universal??

First, many of the dd-wrt users are either running a build that has no room for a JIFFS file system or just dont have much Linux savvey.

My suggestion is to make a stand-alone version of your scripts that can be scp'd (usinf winscp) to /tmp on the router. This version would execute on /tmp and would create its output files in /tmp. These files would then be moved to the users PC - again using winscp.

To restore settings on a new router - simply scp the saved scripts to the /tmp dir on the router and execute them.

No ftp needed, no new directory structure, no additional file systems (CIFF, JIFF, usb, etc).

What do you think??
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Feb 01, 2009 16:45    Post subject: Reply with quote
Well, I agree...

You can do it if you want to. Wink

_________________
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)
dellsweig
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 1476
Location: New York, USA

PostPosted: Sun Feb 01, 2009 17:11    Post subject: Reply with quote
frater wrote:
Well, I agree...

You can do it if you want to. Wink


No problem - here is what I have done

Step 1: on your PC - use winscp to copy backupvars.sh and vars_to_skip to your routers /tmp directory

step 2: using ssh (or telnet) log on to your router. Change directory (cd) to the /tmp directory.

# cd /tmp

Set execute permission on the backupvars.sh script as follows:

# chmod +x /tmp/backupvars.sh

step 3: Run the backup script. My router runs at 100% cpu while this runs so dont be suprised - takes about a minute to complete

# ./backupvars.sh

once complete, the prompt (#) will return. If you look, you will see 3 new files in the /tmp dir

# ls *.sh

MACADDRESS.DATE.all.sh
MACADDRESS.DATE.dangerous.sh
MACADDRESS.DATE.essential.sh

Step 4: Again using winscp on your PC (or your favorite scp client) copy those 3 files into a safe place on your PC


To restore settings on a reset DD-WRT do the following

1) enable ssh access (and telnet if you like)
2) using winscp copy tha appropriate backup file(s) to the /tmp dir on your router

3) using ssh (or telnet) log on to your router. Change directory (cd) to the /tmp directory.

# cd /tmp

Set execute permission on the backupvars.sh script as follows:

# chmod +x /tmp/*.sh

4) execute the appropriate script on the router

# ./MACADDRESS.DATE.all.sh

reboot and your done!!!!

Here is what you need to cut and paste into a file called backupvars.sh:

!/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=/tmp
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
#vUSERPASS=user:pass
nvram show 2>/dev/null | egrep '^[a-zA-Z].*=' | awk -F= '{print $1}' | grep -v "[ /+<>,:;]" | sort -u >/tmp/all_vars
#
echo -e "#!/bin/sh\n#\necho \"Write variables\"\n" | tee -i ${TO_EXCLUDE} | tee -i ${TO_ALL} > ${TO_INCLUDE}
cat /tmp/all_vars | 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 /tmp/all_vars
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}


Copy the following into a file called vars_to_skip


DD_BOARD
^board
browser_method
^cfe
ct_modules
custom_shutdown_command
^def_
^default_
dist_type
dl_ram_addr
early_startup_command
^et0
^et1
^ezc
generate_key
gozila_action
gpio
^hardware
^is_
^kernel_
lan_default
^lan_hw
^lan_ifname
landevs
manual_boot_nv
misc_io_mode
need_commit
^os_
overclocking
pa0maxpwr
phyid_num
pmon_ver
pppd_pppifname
pppoe_ifname
pppoe_wan_ifname
primary_ifname
probe_blacklist
regulation_domain
rescue
reset_
scratch
sdram
^sh_
^skip
sshd_dss_host_key
sshd_rsa_host_key
startup_command
^wan_default
^wan_hw
^wan_if
^wan_vport
^wandevs
web_hook_libraries
^wifi_
wl0.1_hwaddr
wl0.2_hwaddr
wl0.3_hwaddr
wl0_hwaddr
wl0_ifname
wl0_radioids
wl_hwaddr
wl_ifname
^wlan_



router set and exwecute.jpg
 Description:
 Filesize:  59.31 KB
 Viewed:  34178 Time(s)

router set and exwecute.jpg



winscp - move script to router.jpg
 Description:
 Filesize:  127.18 KB
 Viewed:  34178 Time(s)

winscp - move script to router.jpg


zikronix
DD-WRT User


Joined: 21 Feb 2008
Posts: 120

PostPosted: Sun Feb 01, 2009 17:14    Post subject: Reply with quote
i have some linux skills. enought to do this yes. but i jusat had some general questions.

thanks
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Feb 01, 2009 17:23    Post subject: Reply with quote
Thanks dellsweig Wink
_________________
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)
Slione
DD-WRT User


Joined: 05 Dec 2007
Posts: 215
Location: Michigan

PostPosted: Mon Feb 02, 2009 18:13    Post subject: Reply with quote
frater wrote:
Thanks dellsweig Wink


Not only a thanks to him but a thanks to you also Frater! Very Happy Between your scripts and Dellsweig's instructions I have backed up my settings, installed the latest mega version (11536)on my WRT54G-TM router, reinstalled the backed up settings and it worked beautifully!

I only had one thing that did not work correctly and that is the MAC filtering under the Wireless tab. I Allow the users with MACs I've put in the Mac filter list and when the settings were restored it had the Prevent one selected. I tried restoring the settings on another router I have and it did the same thing. Is there something that it's not reading/writing properly?

Other than that it is great!! Very Happy
gene
DD-WRT Guru


Joined: 28 Dec 2007
Posts: 619

PostPosted: Sun Mar 08, 2009 15:39    Post subject: Reply with quote
does this script fail if a var has been added to the firmware or removed by BS or Eko ?

Also, what do I do with the 2 other .sh files that are created ? the one called dangerous and essential ?

_________________
1 WRT160N v3 - remote AP WPA2 Personal Aes dd-wrt-mini-trailed CPU OC400,
2 wrt54G v3(BCM4712 chip rev 1, corerev=7)- AP WPA2 Personal Aes dd-wrt-mini-generic CPU OC228,
1 wrt54gs v6 - remote AP WPA2 Personal Aes dd-wrt-micro CPU OC228 ,
3 WAP54g v3 - repeater, client Bridge, repeater bridge dd-wrt-micro CPU OC225,
1 NetGear WNR2000 v3 AP Atheros AR7241 ver 1 rev 1.1 (0x0101) Trailed build CPU OC360
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).
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Mar 08, 2009 19:40    Post subject: Reply with quote
gene wrote:
does this script fail if a var has been added to the firmware or removed by BS or Eko ?

Also, what do I do with the 2 other .sh files that are created ? the one called dangerous and essential ?


No, the script itself doesn't.

If a var is removed by Brainslayer it will re-appear, which is not a real problem as that var will not be used by the software. It takes however some memory from the var-environment. I could change the script to check for that.
If a var is added by Brainslayer this var will be created anyhow by Brainslayer's initialisation code (defaults.c) .

_________________
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)
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Mar 08, 2009 19:46    Post subject: Reply with quote
Slione wrote:
frater wrote:
Thanks dellsweig Wink


Not only a thanks to him but a thanks to you also Frater! Very Happy Between your scripts and Dellsweig's instructions I have backed up my settings, installed the latest mega version (11536)on my WRT54G-TM router, reinstalled the backed up settings and it worked beautifully!

I only had one thing that did not work correctly and that is the MAC filtering under the Wireless tab. I Allow the users with MACs I've put in the Mac filter list and when the settings were restored it had the Prevent one selected. I tried restoring the settings on another router I have and it did the same thing. Is there something that it's not reading/writing properly?

Other than that it is great!! Very Happy


Can you check if the MAC-addresses were in the .sh file? Did you use "essential"?
If you used "essential" can you check if they were in "all"? Please give the name of the var where they were in.
It's possible the script puts these MACs in "dangerous". If so, this is wrong.

_________________
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)
dave.tchang
DD-WRT User


Joined: 05 Jan 2009
Posts: 53

PostPosted: Sun Mar 08, 2009 21:33    Post subject: Reply with quote
dellsweig wrote:
frater wrote:
Well, I agree...

You can do it if you want to. Wink


No problem - here is what I have done

Step 1: on your PC - use winscp to copy backupvars.sh and vars_to_skip to your routers /tmp directory

step 2: using ssh (or telnet) log on to your router. Change directory (cd) to the /tmp directory.

# cd /tmp




Hi,

First of all a big thank you to both frater and dellsweig for providing us with this wealth of information!

Please bare with me, as I'm completely illiterate in linux stuff! Confused

I have a couple of questions on all of this:

1) Just wondering can I do all of this even on a micro version, or do I need as minimum the mini version of DD-WRT? I'm currently using micro build 11650 VINT EKO on a WRT54G v1.1 router.

2) I downloaded WinSCP (the latest beta version 4.2.1), but I can't figure out which of the options in the SSH tab I need to configure to get connected to the router.

3) When logging in with WinSCP, am I correct in assuming that in "host name" I type in the ip of the router? Do I use the standard "root" (like when using telnet) as "user name"? Do I need a "private key file"?

Your assistence will be greatly appreciated! Many thanks.

Regards
Dave
Antwerp, Belgium
gene
DD-WRT Guru


Joined: 28 Dec 2007
Posts: 619

PostPosted: Sun Mar 08, 2009 22:35    Post subject: Reply with quote
what are the other 2 .sh files supposed to be used for ? instructions said to restore ALL, but there is also essential and dangerous which is empty.
_________________
1 WRT160N v3 - remote AP WPA2 Personal Aes dd-wrt-mini-trailed CPU OC400,
2 wrt54G v3(BCM4712 chip rev 1, corerev=7)- AP WPA2 Personal Aes dd-wrt-mini-generic CPU OC228,
1 wrt54gs v6 - remote AP WPA2 Personal Aes dd-wrt-micro CPU OC228 ,
3 WAP54g v3 - repeater, client Bridge, repeater bridge dd-wrt-micro CPU OC225,
1 NetGear WNR2000 v3 AP Atheros AR7241 ver 1 rev 1.1 (0x0101) Trailed build CPU OC360
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).
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Mar 08, 2009 23:17    Post subject: Reply with quote
All 3 files should be filled.

    All - All variables
    Dangerous - Variables that are hardware specific and should not be loaded on another router. These variables will be created by the firmware anyhow.
    Essential - These variables are safe to load.


Do you have "vars_to_skip" in the same directory?

_________________
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)
Goto page Previous  1, 2, 3, ... 22, 23, 24  Next Display posts from previous:    Page 2 of 24
Post new topic   Reply to topic    DD-WRT 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