#!/usr/bin/env bash
#/ Usage: ghe-backup-strategy
#/
#/ Determine the backup strategy that will be used.
#/
#/ The rsync strategy should be used for single VMs and all HA configurations.
#/
#/ The cluster strategy should be used to backup GHE clusters.
set -e

# Bring in the backup configuration
# shellcheck source=share/github-backup-utils/ghe-backup-config
. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config"

if ghe-ssh "$GHE_HOSTNAME" -- \
  "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ] && [ ! -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then
  echo "cluster"
else
  echo "rsync"
fi
