#!/usr/bin/env bash
#/ Usage: ghe-restore-redis <host>
#/ Restore redis files from an rsync snapshot.
#/
#/ Note: This script typically isn't called directly. It's invoked by the
#/ ghe-restore command.
set -e

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

# Show usage and bail with no arguments
[[ -z ${*} ]] && print_usage

# Grab host arg
GHE_HOSTNAME="${1}"

# Grab snapshot path arg
GHE_RESTORE_SNAPSHOT_PATH="${2}"

bm_start "$(basename "${0}")"

ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb" 1>&3

bm_end "$(basename "${0}")"