From d69d7caf2af92f9f17ecfbdc02aaa941af81a632 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Mon, 20 May 2024 19:02:24 -0500 Subject: [PATCH] updates for being contained in a subdir --- restic_backup.sh | 25 ------------------------- restic_command.sh | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 27 deletions(-) delete mode 100755 restic_backup.sh diff --git a/restic_backup.sh b/restic_backup.sh deleted file mode 100755 index 4b53d9c..0000000 --- a/restic_backup.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) -COMPOSE_FILE=$SCRIPT_DIR/docker-compose.yml - -SERVICES="server db" - -echo -n "Stopping containers..." -docker compose -f $COMPOSE_FILE stop $SERVICES 2>/dev/null -echo "Done" - -echo -n "Running backup..." -$SCRIPT_DIR/restic_command.sh backup /data "$@" -echo "Done" - -echo -n "Executing compose up..." -docker compose -f $COMPOSE_FILE up -d 2>/dev/null -echo "Done" - -echo -n "Pruning restic repo..." -$SCRIPT_DIR/restic_prune.sh 1>/dev/null -echo "Done" - -SPACE=$(du -hs /mnt/* | awk '{print $1}') -echo "Total space used: $SPACE" diff --git a/restic_command.sh b/restic_command.sh index 736bfb6..61af26f 100755 --- a/restic_command.sh +++ b/restic_command.sh @@ -3,11 +3,27 @@ set -e SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) -DATA_DIR=$SCRIPT_DIR/data +REPO_DIR=$(dirname $SCRIPT_DIR) -ENV_FILE=$SCRIPT_DIR/.env +ENV_FILE=$REPO_DIR/.env +echo "Reading env variables from $ENV_FILE" source $ENV_FILE +if [ -z "$DATA_DIR" ]; then + echo "Error: DATA_DIR is not set." + exit 1 +fi + +if [ -z "$RESTIC_REPOSITORY" ]; then + echo "Error: RESTIC_REPOSITORY is not set." + exit 1 +fi + +if [ -z "$RESTIC_PASSWORD" ]; then + echo "Error: RESTIC_PASSWORD is not set." + exit 1 +fi + docker run -it --rm \ --hostname $HOSTNAME \ --env-file $ENV_FILE \