#!/bin/zsh
# Saves OBS profiles, scene collections and settings to ~/.config/stream-kit/backups before any change.
# Leaves out the OBS browser cache, which holds website logins.
set -e
OBS="$HOME/Library/Application Support/obs-studio"
OUT="$HOME/.config/stream-kit/backups"
[[ -d "$OBS" ]] || { echo "No OBS settings folder yet. Open OBS once, then run this again."; exit 1; }
mkdir -p "$OUT"
items=()
for p in basic global.ini user.ini plugin_config/obs-websocket; do
  [[ -e "$OBS/$p" ]] && items+=("$p")
done
FILE="$OUT/obs-$(date +%Y%m%d-%H%M%S).tgz"
tar -czf "$FILE" -C "$OBS" "${items[@]}"
chmod 600 "$FILE"
echo "$FILE"
