database copying and compacting

David Relson relson at osagesoftware.com
Sun Nov 7 16:17:27 CET 2004


Matthias,

Sanity check please :-)

The copying and compacting of databases has gotten more complex with the
new release.  BerkeleyDB's Transaction capability generates log files
which need to be included when copying and compacting.  I suspect I'll
have db_copy and db_compact scripts before much longer.  Before I go too
far in that direction, I wanted to check my understanding with you.

1) With 0.92.8, database copying was as simple as:

    cp $ORIG/wordlist.db $NEW/

Now, with 0.93.0 it's necessary to save log files and use dd (with
proper block size) when copying the database.  Thus copying becomes:

   SIZE=`db_stat -h $ORIG -d wordlist.db | grep "page size" | cut -f 1` 
   cp $SRC/log* $SRC/__db.* $DST  
   for FILE in $SRC/*.db ; do
       dd bs=$SIZE if=$FILE of=$DST/`basename $FILE`
   done

The for loop supports multiple databases, e.g. wordlist.db and
ignore.db, in $SRC

2) With 0.92.8, database compacting (with backup) looked like:

    bogoutil -d $ORIG/wordlist.db > $NEW/wordlist.txt
    bogoutil -l $NEW/wordlist.db  < $NEW/wordlist.txt
    mv $ORIG/wordlist.db $ORIG/wordlist.db.orig
    mv -f $NEW/wordlist.db $ORIG/wordlist.db

Now, with 0.93.0 it's:

    bogoutil -d $ORIG/wordlist.db > $NEW/wordlist.txt
    bogoutil -l $NEW/wordlist.db  < $NEW/wordlist.txt
    mv $ORIG/wordlist.db $ORIG/wordlist.db.orig
    mv -f $NEW/wordlist.db $ORIG/wordlist.db
    cd $NEW
    db_checkpoint -1 -h .
    rm -f `db_archive -h .`

As I understand it, db_checkpoint ensures that the log file contents are
included in the database (as far as possible) and db_archive lists log
files that can be deleted.

Is the above info accurate?  Do you see any problems with it?

Regards,

David



More information about the Bogofilter mailing list