Skip to content

Commit

Permalink
taking another shot at fixing the backup
Browse files Browse the repository at this point in the history
  • Loading branch information
ennorehling committed Jul 27, 2023
1 parent ca4604f commit 4d727a7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
12 changes: 3 additions & 9 deletions process/backup-eressea
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
#!/bin/bash
DIR=$(dirname $0)
source "$DIR/boxcli.sh"
if [ -z "$ERESSEA" ] ; then
ERESSEA="$HOME/eressea"
echo "The ERESSEA environment variable is not set. Assuming $ERESSEA."
fi
GAME=$1

upload() {
SRC="$1"
DST=$(basename "$SRC")
SELECT=".name=\"$DST\""
FILE_ID=$(box folders:get --json 2654558997 | jq ".item_collection.entries[] | select($SELECT) | .id" | tr -d \")
if [ -n "$FILE_ID" ]; then
box files:upload -p 2654558997 "$SRC"
else
box files:versions:upload "$FILE_ID" "$SRC"
fi
box-upload "$1"
}

if [ ! -d "$ERESSEA/game-$GAME" ]; then
Expand Down
36 changes: 36 additions & 0 deletions process/boxcli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

box-upload-id() {
SRC="$1"
DST="$2"
FOLDER_ID="$3"
box files:upload -q -p "$FOLDER_ID" -n "$DST" "$SRC"
}

box-update-id() {
SRC="$1"
FILE_ID="$2"
box files:versions:upload -q "$FILE_ID" "$SRC"
}

box-file-id() {
FOLDER_ID="$1"
FILE="$2"
box folders:get --json \
"$FOLDER_ID" | jq ".item_collection.entries[] | select(.name==\"$FILE\") | .id" | tr -d \"
}

box-upload() {
SRC="$1"
DST=$(basename "$SRC")
FOLDER_ID=2654558997
FILE_ID=$(box-file-id "$FOLDER_ID" "$DST")
if [ -z "$FILE_ID" ] ; then
echo upload
box-upload-id "$SRC" "$DST" "$FOLDER_ID"
else
echo update
box-update-id "$SRC" "$FILE_ID"
fi
}

0 comments on commit 4d727a7

Please sign in to comment.