#!/bin/bash ################################################################################################## ############################## Master Variables for unRAID scripts ################################ ################################################################################################## # Define the hostnames of both servers HOST1="unRAID-Gmer4Lfe" HOST2="unRAID-Jayred365" # Detect local hostname LOCAL_HOSTNAME="$(hostname)" if [[ "$LOCAL_HOSTNAME" == "$HOST1" ]]; then LOCAL_SERVER_NAME="$HOST1" REMOTE_SERVER_NAME="$HOST2" elif [[ "$LOCAL_HOSTNAME" == "$HOST2" ]]; then LOCAL_SERVER_NAME="$HOST2" REMOTE_SERVER_NAME="$HOST1" else echo "Error: Local hostname ($LOCAL_HOSTNAME) not recognized." exit 1 fi echo "Local server: $LOCAL_SERVER_NAME" echo "Remote server: $REMOTE_SERVER_NAME" # Resolve Tailscale IP dynamically, This will try to get the Tailscale IPv4 address for that host REMOTE_SERVER=$(tailscale ip -4 "$REMOTE_SERVER_NAME" 2>/dev/null) if [[ -z "$REMOTE_SERVER" ]]; then echo "Error: Could not resolve Tailscale IP for $REMOTE_SERVER_NAME" exit 1 fi # SSH key mapping per hostpair declare -A SSH_KEYS SSH_KEYS["$HOST1|$HOST2"]="/root/.ssh/Gmer4Lfe-rsync-key" SSH_KEYS["$HOST2|$HOST1"]="/root/.ssh/Jayred365-rsync-key" KEY_ID="$LOCAL_SERVER_NAME|$REMOTE_SERVER_NAME" if [[ -n "${SSH_KEYS[$KEY_ID]}" ]]; then SSH_KEY="${SSH_KEYS[$KEY_ID]}" else echo "Error: No SSH key defined for $LOCAL_SERVER_NAME → $REMOTE_SERVER_NAME" exit 1 fi echo "Using SSH key: $SSH_KEY" # Network speed limit 100Mbps=12500 KB/s, 200Mbps=25600 KB/s BW_LIMIT=12500 # Amount of times to retry RETRY_COUNT=3 # Time in seconds waiting to retry SLEEP=300 # Max number of concurrently running rsync processes MAX_RSYNC_PROCS=1 # Containers to stop/start on backup server CRITICAL_CONTAINER_NAMES=() # Containers from CRITICAL_CONTAINER_NAMES that should have delayed startup DELAYED_CONTAINERS=() # Time in seconds to delay the listed containers CONTAINER_DELAY=5