#!/usr/bin/env bash
# Push volledige foodlinkk-command-center naar Gitea (VM106).
set -euo pipefail

HOST="${DEPLOY_HOST:-aissa@10.4.7.18}"
REASON="${1:-manual-backup}"

echo "=== Rsync naar VM106 ==="
rsync -az --exclude '.git' --exclude '__pycache__' --exclude 'node_modules' \
  "$(dirname "$0")/../" "${HOST}:~/foodlinkk-command-center/"

echo "=== Gitea sync via tools-api ==="
ssh "$HOST" "docker exec foodlinkk_tools_api python -c \"
from app.connectors.gitea_repo_sync import run_gitea_repo_sync
import json
print(json.dumps(run_gitea_repo_sync('${REASON}'), indent=2))
\""

echo "=== Klaar — Gitea: http://10.4.7.18:3001/aissa/foodlinkk-command-center ==="
