#!/bin/bash
# sync_gafa30_to_prod.sh

LOCAL_DIR="/chemin/local/gafa30/web/"
REMOTE_USER="user"
REMOTE_HOST="khagi.info"
REMOTE_DIR="/home/gafa.khagi.info/public_html/web/"

rsync -avz --delete \
  --exclude='.git/' \
  --exclude='.ddev/' \
  --exclude='vendor/' \
  --exclude='node_modules/' \
  --exclude='sites/default/' \
  --exclude='*.local.php' \
  --include='sites/gafa.khagi.info/' \
  --include='modules/custom/' \
  --include='themes/custom/' \
  -e ssh "$LOCAL_DIR" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR"

# Post-sync
ssh "$REMOTE_USER@$REMOTE_HOST" "
  chown -R gafa:gafa /home/gafa.khagi.info/public_html/web/sites/gafa.khagi.info/files
  drush -r $REMOTE_DIR cr
"