#!/bin/bash

if [ -z "$1" ]; then
    echo "Must specify backup host"
    exit 1
fi

BORG="/opt/borg/bin/borg"

# Setting this, so the repo does not need to be given on the commandline:
export BORG_REPO="ssh://{{ borg_username}}@${1}/opt/backups/{{ borg_username }}/backup"

# some helpers and error handling:
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }

info "Mounting backup to /opt/backups"

mkdir -p /opt/backups
$BORG mount $BORG_REPO /opt/backups

info "To unmount: $BORG umount /opt/backups"