#!/bin/sh
#
PATH=/bin:/usr/bin:/usr/local/bin:.; export PATH
#
. mush.config
#
# You'll want to use gzip if you have it. If you want really good
# compression, try 'gzip --best'. If you don't have gzip, use 'compress'.
ZIP=gzip
#
DBDATE=`date +%m%d-%H%M`
#
if [ -r $NEW_DB ]; then
    ./dbconvert $GDBM_DB x < $NEW_DB | $ZIP -c > $GAMENAME.$DBDATE.gz
else
    if [ -r $INPUT_DB ]; then
        echo "No recent checkpoint db. Using older db."
        ./dbconvert $GDBM_DB x < $INPUT_DB | $ZIP -c > $GAMENAME.$DBDATE.gz
    else
        if [ -r $SAVE_DB ]; then
            echo "No input db. Using backup db."
            ./dbconvert $GDBM_DB x < $SAVE_DB | $ZIP -c > $GAMENAME.$DBDATE.gz
        else
            echo "No dbs. Backup attempt failed."
        fi
    fi
fi


