Backup & restore of your Tomato-based router statistics

Since I recently moved, and now have my Tomato based WRT54GL on 24/7, I also wanted a way to keep a backup of those nice statistics the router generates. You have the option (built-in) to write them to nvram or to a CIFS share, but the former has a limited amount of writes, and the latter is not really stable (and I don’t have anything powered on all the time to keep the backups on).

I found some nice scripts on gulbsoft.de that showed how to make backups on an ftp/website combination, but I wanted to move this to an internet-host (since that thing IS up 24/7 in contrast to my inhouse infrastructure) and I didn’t really like them, I ‘redesigned’ them.

Lo and behold!

The only thing you need to do is put this in your WAN-up script:

killall rstats

URL="http://your.web.page.address"
FTP="ftp.server.name"
USER="username"
PW="password"
STATSDIR="/tmp/var/lib/misc"
FTPSCRIPT="/tmp/ftpbackup.sh"
FILES="rstats-history.gz rstats-speed.gz rstats-stime rstats-source"

cat > $FTPSCRIPT << EOF
for FILE in $FILES; do
  ftpput -u $USER -p $PW $FTP \$FILE $STATSDIR/\$FILE
done
EOF
chmod a+x $FTPSCRIPT

cru d bkstat
cru a bkstat "2,15,30,45 * * * * $FTPSCRIPT"
cd $STATSDIR
rm $FILES
for FILE in $FILES; do
  wget $URL/$FILE
done
sleep 10
rstats

Don’t forget to change the lines reading URL, FTP, USER and PW to your respective website address, ftp server name, ftp login name and ftp password!

wrt54g time to live exceeded?

I wonder how long the lifetime is of a Linksys WRT54G v2.2 router… I have one, and it’s been showing more and more problems with the WiFi part of the router: often after a powerup it just doesn’t initialise, no WiFi to be seen. The router reports it’s up, but there just isn’t any signal.

It usually takes 2-3 powercycles (unplugging and replugging the power) to get it running. Kinda annoying if half of your infrastructure depends on said WiFi :p and the router is on another floor :p

I just swapped my WRT54GL (that I used in a WDS setup) with the WRT54G, and now the internet-connected router is working well but the WDS one isn’t :p Time to either:

  • use my spare WRT54G v5 (which is flashed with dd-wrt micro)
  • buy a new WRT54GL (and flash it using Tomato – what I use now on my routers)

I’ll see. I still have a voucher for MediaMarkt that I need to use… ;)