[ previous ] [ next ] [ threads ]
 
 From:  Jim Gifford <jim at giffords dot net>
 To:  m0n0wall at lists dot m0n0 dot ch
 Subject:  Re: [m0n0wall] confix.xml in ramdisc?
 Date:  Thu, 29 Jan 2004 13:29:10 -0500
On Thu, Jan 29, 2004 at 07:07:37PM +0100, fisch wrote:
> hi,
> on every change of rules m0n0wall is writing to floppy. That's no problem
> but I don't trust the lifetime of a floppy. Is it possible to copy the
> config.xml after boot to ramdisk and use it there? Saving the config.xml
> back to floppy can be done with the exec.php.
> by fisch

I have to agree that writing every time is a concern.  The other night I
lost my config due to a floppy dieing mid-write.  It took me several
hours to scrounge up a functioning floppy, and restore the config.xml
from backup, and then get m0n0wall to re-read the floppy due to it having
a bad copy cached.

I did lose a few changes I had made, but it didn't take me long to put
them back.

Perhaps having an option to save all changes (ie, sync to CF/floppy) and
having the changes not be immediately saved would be good.

For this reason, I'm planning to replace my PC/CDROM/Floppy setup with a
net4801.

After my minor problem with the floppy, I wrote a quick little shell
script that I call from cron to grab the current config.xml and commit it
to CVS for me.  Now, I can get any of the older copies.  I can run the
script by hand to grab changes before the hour is up.  I don't have to
worry in case I forget, because it will get backed up within an hour.

I named my module in cvs 'backup' for simplicity.  I call this script
from cron ever hour at 3 minutes past the hour.  This script is ugly, not
commented, and took perhaps 10 minutes to write and test.  However, it
gets the job done for me.  Perhaps others will find it useful.  I'm
including it below.

jim

----------------- cut here --------------------
#!/bin/sh
# m0n0back -- backup up a m0n0wall config and puts it into cvs
# depends on: sh, curl, cvs, date, rm

CVSROOT=/cvs
export CVSROOT
CVSPROJ=backup
M0N0IP=192.168.1.1
PROTO=http
USER=admin
PASS=XXXXXX
TMPDIR=/tmp/$$

mkdir $TMPDIR
cd $TMPDIR

cvs -Q co $CVSPROJ
cd $CVSPROJ

curl -s -o config.xml -F Submit=download -u ${USER}:${PASS} ${PROTO}://$M0N0IP/diag_backup.php

NOW=`date +%Y-%m-%d@%H:%M:%S`
cvs -Q commit -m "backup of config.xml [$NOW]"

cd /tmp
rm -rf $TMPDIR