Skip to content

Commit

Permalink
sample backup scripts for boc and onedrive
Browse files Browse the repository at this point in the history
  • Loading branch information
ennorehling committed Apr 1, 2024
1 parent 4b142de commit d66564c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
2 changes: 1 addition & 1 deletion process/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
install(PROGRAMS create-orders backup-eressea run-turn send-zip-report
install(PROGRAMS create-orders backup-* run-turn send-zip-report
send-bz2-report compress.py compress.sh epasswd.py
accept-orders.py getemail.py checkpasswd.py
sendreport.sh sendreports.sh orders-accept DESTINATION bin)
Expand Down
File renamed without changes.
44 changes: 44 additions & 0 deletions process/backup-onedrive
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
DIR=$(dirname $0)
if [ -z "$ERESSEA" ] ; then
ERESSEA="$HOME/eressea"
echo "The ERESSEA environment variable is not set. Assuming $ERESSEA."
fi
GAME=$1

upload() {
onedrive-cli cp "./$1" "Eressea/game-$GAME"
}

if [ ! -d "$ERESSEA/game-$GAME" ]; then
echo "No such game: game-$GAME."
exit 1
fi
cd "$ERESSEA/game-$GAME" || exit
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 "$HOME/backup/eressea/game-$GAME"
ln -sf "$HOME/backup/eressea/game-$GAME" backup
fi

if [ -e reports/reports.txt ] ; then
echo "backup reports $TURN, game $GAME"
tar cjf "backup/$TURN-reports.tar.bz2" reports eressea.db
upload "backup/$TURN-reports.tar.bz2"
fi
files=("data/$TURN.dat" parteien.full parteien)
if [ -e "orders.$TURN" ]; then
files+=("orders.$TURN")
fi
echo "backup turn $TURN, game $GAME, files: ${files[*]}"
tar cjf "backup/$TURN.tar.bz2" "${files[@]}"
upload "backup/$TURN.tar.bz2"

15 changes: 11 additions & 4 deletions process/cron/run-eressea.cron
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ GAME=$1
[ "$ENABLED" == "no" ] && exit
[ -z "$ERESSEA" ] && ERESSEA="$HOME/eressea"

backup()
{
if [ -x "$BIN/backup-eressea" ] ; then
"$BIN/backup-eressea" "$1" "$2"
fi
}

export ERESSEA
eval "$(luarocks path)"
export LUA_PATH="${ERESSEA}/server/scripts/?.lua;$LUA_PATH"
Expand Down Expand Up @@ -37,12 +44,12 @@ if [ ! -s "orders.$TURN" ]; then
exit 2
fi

"$BIN/backup-eressea" "$GAME" "$TURN"
backup "$GAME" "$TURN"
rm -f execute.lock
"$BIN/run-turn" "$GAME" "$TURN"
touch execute.lock

let NEXTTURN=$TURN+1
(( NEXTTURN=TURN+1 )) || true
if [ ! -e "$DATA/$NEXTTURN.dat" ]; then
echo "server did not create data file $NEXTTURN.dat"
exit 5
Expand All @@ -51,7 +58,7 @@ if [ ! -s "$REPORTS/reports.txt" ]; then
echo "server did not create reports.txt in game $GAME"
exit 4
fi
"$BIN/backup-eressea" "$GAME" "$TURN"
backup "$GAME" "$TURN"
TURN=$NEXTTURN
if [ ! -s "$ERESSEA/game-$GAME/data/$TURN.dat" ]; then
echo "server did not create data for turn $TURN in game $GAME"
Expand All @@ -65,7 +72,7 @@ fi
echo "sending reports for game $GAME, turn $TURN"
"$BIN/compress.sh" "$GAME" "$TURN"
"$BIN/sendreports.sh" "$GAME"
"$BIN/backup-eressea" "$GAME" "$TURN"
backup "$GAME" "$TURN"
rm -f test/execute.lock
) | tee -a "$HOME/log/eressea.cron.log"

1 change: 1 addition & 0 deletions src/kernel/save.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "race.h"
#include "region.h"
#include "ship.h"
#include "skill.h"
#include "unit.h"
#include "version.h"

Expand Down

0 comments on commit d66564c

Please sign in to comment.