PDA

Bekijk de volledige versie : "Backup/disaster recovery" strategy for WL500gP



n-joy
07-07-2007, 09:38
Hi there,

I am trying to put a backup/disaster recovery strategy in place for a WL500gP box.
There are several packages installed and configured on this box and I would like to avoid having to reconfigure the router again in case of a disaster. This would save a lot of time and ensure a good availability for the router.

I was thinking on the following:

1. Export the full image from the router:

dd if=/dev/mtd/1ro of=/tmp/harddisk/backup/today.trx

2. Backup the "opt" partition with a backup application (e.g. partimage (http://www.partimage.org/Main_Page) or flexbackup (http://www.linuxsoft.cz/en/sw_detail.php?id_item=5541) in a different place (e.g. /tmp/harddisk/backup/opt/)

Question: As I found out, the `dd` command copies also empty blocks and I am not sure if this will result in a valid TRX file. Does anyone have experience in this?
What do you think?

Thank you in advance!
n-joy

al37919
07-07-2007, 11:06
At some moment of time I also realized that I invested good amount of time and efforts in this box :) which I really don't want to learn again from zero if something happens...

I use 2 scripts to perform daily backup of what I might have changed:

/opt/etc/cron.d/backup_fs.sh

#! /bin/sh
PATH="/opt/local/bin:/opt/sbin:/opt/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin"


x=10;
while [ `date +%Y` -eq 1970 ]
do
sleep 5m
x=$(($x-1))
[ $x -eq 0 ] && exit 1
done

TIMESTAMP=`date +%Y%m%d`

flashfs save

mkdir -p /tmp/nvram
cat /dev/mtd/3 > /tmp/nvram/nvram.bin
nvram show > /tmp/nvram/nvram.txt

cat /dev/mtd/4 > /tmp/flashfs.bin
tar cvfz /opt/tmp/save/fs/$TIMESTAMP.tar.gz /opt/etc /opt/local /tmp/nvram /tmp/flash.tar.gz /tmp/flashfs.bin /opt/tmp/amule/Temp/*.met

/opt/etc/cron.d/backup_syslog.sh

#! /bin/sh
PATH="/opt/local/bin:/opt/sbin:/opt/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin"

LOG_FILE=/opt/var/log/syslog.log
LOG_DESTINATION=/opt/var/log/arv
#my cron runs cron.daily at 00:00, therefore I store daily log with yesterday's date
TIMESTAMPEDFILENAME=`date +%Y%m%d_syslog.log`

mv "$LOG_FILE" "$LOG_DESTINATION/$TIMESTAMPEDFILENAME"
touch $LOG_FILE
gzip "$LOG_DESTINATION/$TIMESTAMPEDFILENAME"


You see I save only limited amount of locations, but I put an effort to arrange all in such a way that /opt/etc contains all configuration files, /opt/local contains all programs which I compiled and installed besides ipkg package system, plus nvram and flashfs.

The positive thing is that backup is daily automated through cron, the negative is that the tar.gz file is saved in the same hdd, from which I copy these archives sometimes to external storage.

n-joy
10-07-2007, 16:42
Hi al37919,

Thank you for your reply. Looks quite interesting!! :)

My beginner (in the Linux world) question would be: How would you restore the "nvram.bin" and "flashfs.bin" files back to the box?

Additionally (as the files are not too big) you could use a mail client to send them as attachments to a gmail address. You could set this to a weekly schedule to avoid generating too much traffic. This will ensure an even higher availability for the backup files and would cover also the hazard case where the HDD breaks down at the same time.

Br,
n-joy

zzzpt
10-07-2007, 17:23
too bad i'm seeing this now.
Today something very stranged happened.

I formatted my PC, put the windows xp 64 bit... Instaled drivers....
And the 1st time it recognized (via samba) the external disk connected to the router.
Well since i didnt do anything to the router or the disk, it was suposed that everything should be like it was, before the format.

But some restarts later...
I found that it didnt find the disk....:confused:
Went to the router site, and it was reseted ... (user and password: admin/admin)

Well going to configure all again...

al37919
11-07-2007, 07:01
My beginner (in the Linux world) question would be: How would you restore the "nvram.bin" and "flashfs.bin" files back to the box?
My "guru's" answer will be I don't know. :) (In principle I think it should look like
cat nvram.bin > /dev/mtd/X
but I will think seven times before I do something like this)


Went to the router site, and it was reseted ... (user and password: admin/admin)
Try to issue:
flashfs enable

n-joy
11-07-2007, 08:25
Ok. In this case I will try to find out what can be done to have a proof recovery scenario.

In the mean while, if someone else knows how to restore a box from the nvram and flashfs files or tried to do this, is more than welcome to share with us his/her experience (even if it's not a happy one).;)

bakablah
26-08-2007, 14:40
All i backed up was the flashfs.tar.gz and the router cfg file from the website, at one point my router refused to boot up and cannot get an IP address, I had to do a firmware restore (press restore while powering up the router), flashed the router again with the oleg's firmware. Then i mounted my hdd again, copied the flashfs file to /tmp/ as flash.tar.gz and typed flashfs commit, and flashfs enable.

Since the files in the hdd partitions are not touched, i didn't lose any data.
The only thing i lost is the small changes i made that caused the crash.