From ff071d1d30c517fcf7cec34db3ac8f54f5de7054 Mon Sep 17 00:00:00 2001 From: John Gaunt Date: Tue, 17 Aug 2021 15:49:38 -0400 Subject: [PATCH] added logic for gauntnas local backup --- restic.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/restic.sh b/restic.sh index 5653ab2..4948bc8 100644 --- a/restic.sh +++ b/restic.sh @@ -3,8 +3,17 @@ LOCKFILE="/tmp/restic.lock" LOGFILE="/var/log/restic/restic_$(date +%Y%m%d-%H%M%S).log" LATEST_RESTIC_VERSION="0.12.1" -RESTIC_REPOSITORY="sftp:root@gauntnas.home.johnhgaunt.com:50022:/mnt/restic" -RESTIC_PASSWORD="restic" +LOCAL_RESTIC_REPOSITORY="/mnt/data/backups/restic" +export RESTIC_REPOSITORY="sftp:root@gauntnas.home.johnhgaunt.com:50022:/mnt/restic" +export RESTIC_PASSWORD="restic" + +if [ -d ${LOCAL_RESTIC_REPOSITORY} ]; then + restic --repo ${LOCAL_RESTIC_REPOSITORY} snapshots + if [ ${?} == "0" ]; then + export RESTIC_REPOSITORY=${LOCAL_RESTIC_REPOSITORY} + fi +fi + # make log directory if [ ! -d $(dirname ${LOGFILE}) ]; then