diff --git a/create_restic_repo.sh b/create_restic_repo.sh index 7eb28dd..45d288b 100755 --- a/create_restic_repo.sh +++ b/create_restic_repo.sh @@ -1,16 +1,20 @@ #!/bin/bash +set -e -if [ "$#" -ne 1 ]; then - echo "$(tput setaf 1)No repo name specified$(tput sgr0)" - echo "Usage: $0 " - exit 1 -else - # Assign the directory to a variable - REPO_PATH=/mnt/backups/$1 - echo -e "Creating $(tput setaf 4)$REPO_PATH$(tput sgr0)" +if [ -z "${RESTIC_DIR}" ]; then + if [ "$#" -ne 1 ]; then + echo "$(tput setaf 1)No repo name specified$(tput sgr0)" + echo "Usage: $0 " + echo "Or have the RESTIC_DIR variable set" + exit 1 + else + RESTIC_DIR=$(readlink -f $1) + fi fi +echo "RESTIC_DIR is $(tput setaf 4)$RESTIC_DIR$(tput sgr0)" + docker run -it --rm \ --v /mnt/backups:/mnt/backups \ +-v $RESTIC_DIR:$RESTIC_DIR \ restic/restic \ -init --repo $REPO_PATH \ No newline at end of file +init --repo $RESTIC_DIR