From 489ef570dd6525b3244d5b5f5809701877a8a65e Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Tue, 9 Nov 2021 14:30:19 +0200 Subject: [PATCH] Fix AWS S3 settings --- backup.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backup.sh b/backup.sh index 109258d..991c371 100755 --- a/backup.sh +++ b/backup.sh @@ -6,6 +6,8 @@ restic_password_file="${RESTIC_PASSWORD_FILE:?RESTIC_PASSWORD_FILE not set}" restic_host="${RESTIC_HOST:?RESTIC_HOST not set}" +backup_path="${BACKUP_DEST:?BACKUP_DEST not set}" + ssh_key_file="${SSH_KEY_FILE}" s3_key_file="${AWS_SECRET_ACCESS_KEY_FILE}" @@ -18,8 +20,9 @@ if [ -n "$ssh_key_file" ] && [ -f "$ssh_key_file" ]; then fi if [ -n "$s3_key_file" ] && [ -f "$s3_key_file" ]; then - export "$AWS_SECRET_ACCESS_KEY"="$(cat "${s3_key_file}")" - restic_repo="s3:$restic_host:/$server_name" + AWS_SECRET_ACCESS_KEY="$(cat "${s3_key_file}")" + export AWS_SECRET_ACCESS_KEY + restic_repo="s3:$restic_host$server_name" fi if [ -z "$restic_repo" ]; then @@ -27,6 +30,8 @@ if [ -z "$restic_repo" ]; then exit 1 fi +echo "restic_repo: $restic_repo" + # Pre-bake-in some default restic options _restic() { # shellcheck disable=SC2068 @@ -36,8 +41,6 @@ _restic() { $@ } -backup_path="${BACKUP_DEST:?BACKUP_DEST not set}" - if [ -n "$SERVICES_OVERRIDE" ]; then # this is fine because docker service names should never include spaces or # glob characters @@ -82,7 +85,7 @@ for service in "${services[@]}"; do fi done -# Check if restic repo exists +# check if restic repo exists, initialise if not if [ -z "$(_restic cat config)" ] 2>/dev/null; then echo "initializing restic repo" _restic init