Files
TSSBOT/fetch_replays.sh
T
NotSoToothless 7bd8a1b72c -am (#1329)
2026-06-17 00:32:30 -07:00

39 lines
1.0 KiB
Bash

#!/usr/bin/env bash
# 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 \
"${INCLUDES[@]}" \
--exclude="*" \
"${REMOTE}:${REMOTE_PATH}" \
"$LOCAL_PATH/"
echo "Done. Files in: $LOCAL_PATH"