From fc98619d3c6c7189449da6373ac4348291f8502f Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Sun, 19 May 2024 19:58:52 -0500 Subject: [PATCH] old WIP on the create_restic_repo script --- create_restic_repo.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) 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