#!/usr/bin/env bash
set -e

# import .env config
set -o allexport
source $(dirname "$0")/.env
set +o allexport

for var in "SSH_USERNAME" "SSH_HOST" "UPLOADS_DIRECTORY"
do
  if [[ -z "${!var}" ]]; then
    echo "${var} is undefined"
    exit 1
  fi
done

rsync --archive --update --verbose ${SSH_USERNAME}@${SSH_HOST}:${UPLOADS_DIRECTORY}/ ${OUTPUT_DIRECTORY}
