server/process/backup-eressea

46 lines
1.1 KiB
Text
Raw Permalink Normal View History

#!/bin/bash
if [ -z $ERESSEA ] ; then
ERESSEA=$HOME/eressea
echo "The ERESSEA environment variable is not set. Assuming $ERESSEA."
fi
GAME=$1
2019-05-26 20:01:28 +02:00
upload() {
SRC="$1"
DST=$(basename "$SRC")
echo put "$SRC" "$DST" | cadaver "https://dav.box.com/dav/Eressea/game-$GAME/"
}
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
2019-02-17 11:56:11 +01:00
if [ -e reports/reports.txt ] ; then
echo "backup reports $TURN, game $GAME"
2019-09-23 17:32:58 +02:00
tar cjf backup/$TURN-reports.tar.bz2 reports eressea.db
2019-05-26 20:01:28 +02:00
upload backup/$TURN-reports.tar.bz2
2019-02-17 11:56:11 +01:00
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"
tar cjf backup/$TURN.tar.bz2 $files
2019-05-26 20:01:28 +02:00
upload backup/$TURN.tar.bz2