server/process/backup-eressea
2018-10-28 21:55:34 +01:00

37 lines
1 KiB
Bash
Executable file

#!/bin/bash
if [ -z $ERESSEA ] ; then
ERESSEA=$HOME/eressea
echo "The ERESSEA environment variable is not set. Assuming $ERESSEA."
fi
GAME=$1
if [ ! -d $ERESSEA/game-$GAME ]; then
echo "No such game: game-$GAME."
exit 1
fi
cd $ERESSEA/game-$GAME
TURN=$2
if [ -z $TURN ]; then
TURN=$(cat turn)
fi
if [ ! -e data/$TURN.dat ]; then
echo "No data for turn $TURN in game $GAME."
exit 2
fi
if [ ! -d backup ] ; then
echo "creating missing backup directory for game $GAME."
mkdir -p ~/backup/eressea/game-$GAME
ln -sf ~/backup/eressea/game-$GAME backup
fi
files="data/$TURN.dat parteien.full parteien"
if [ -e orders.$TURN ]; then
files="$files orders.$TURN"
fi
echo "backup turn $TURN, game $GAME, files: $files"
if [ -d reports ] ; then
tar cjf backup/$TURN-reports.tar.bz2 reports
fi
tar cjf backup/$TURN.tar.bz2 $files
echo "uploading game-$GAME/$TURN.tar.bz2"
curl -s -n -T backup/$TURN.tar.bz2 https://dav.box.com/dav/Eressea/game-$GAME/$TURN.tar.bz2
#curl -s -n -T eressea.db https://dav.box.com/dav/Eressea/eressea.db