-am (#1329)
This commit is contained in:
+22
-4
@@ -1,18 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pull TSS replay dirs from the server for local study.
|
||||
# Run once manually: bash fetch_replays.sh
|
||||
# Pull the latest TSS replay dirs from the server for local study.
|
||||
# Run once manually: bash fetch_replays.sh [COUNT] (default COUNT=10)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REMOTE="srebot"
|
||||
REMOTE_PATH="/mnt/HC_Volume_105581488/STORAGE/REPLAYS/TSS/"
|
||||
LOCAL_PATH="./replays_sample"
|
||||
COUNT="${1:-10}"
|
||||
|
||||
mkdir -p "$LOCAL_PATH"
|
||||
|
||||
# Grab the COUNT most-recently-modified replay dirs (newest first).
|
||||
mapfile -t DIRS < <(ssh "$REMOTE" "cd '$REMOTE_PATH' && ls -1dt */ 2>/dev/null | head -n $COUNT")
|
||||
|
||||
if [ "${#DIRS[@]}" -eq 0 ]; then
|
||||
echo "No replay dirs found on ${REMOTE}:${REMOTE_PATH}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Pulling ${#DIRS[@]} latest replay dir(s):"
|
||||
printf ' %s\n' "${DIRS[@]}"
|
||||
|
||||
# Build include filters: each dir + its replay_data.json.gz, exclude the rest.
|
||||
INCLUDES=()
|
||||
for d in "${DIRS[@]}"; do
|
||||
d="${d%/}"
|
||||
INCLUDES+=( --include="${d}/" --include="${d}/replay_data.json.gz" )
|
||||
done
|
||||
|
||||
rsync -avz --progress \
|
||||
--include="*/" \
|
||||
--include="replay_data.json.gz" \
|
||||
"${INCLUDES[@]}" \
|
||||
--exclude="*" \
|
||||
"${REMOTE}:${REMOTE_PATH}" \
|
||||
"$LOCAL_PATH/"
|
||||
|
||||
Reference in New Issue
Block a user