commit 5aa78f7a1a42e91a5a26293a2361a78c38e1cae3 Author: Paul Wilde Date: Tue Jan 17 12:21:39 2023 +0000 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..137e678 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +env.sh diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..f7ad944 --- /dev/null +++ b/backup.sh @@ -0,0 +1,19 @@ +#!/bin/bash +source env.sh +echo "Backup $NAME at $DATE" +BACKUP_CMD=restic backup $BACKUP_DIR $BACKUP_PARAMS -e $BACKUP_EXCLUSIONS +running=$(pgrep -f "$BACKUP_CMD") +if [[ $running ]]; then + echo "Backup alreadying running : $running. Exiting..." + curl https://hc-ping.com/$HEALTHCHECK_UUID/fail + exit +fi +echo "Not currently running. Continuing..." +curl https://hc-ping.com/$HEALTH_UUID/start +$PRE_RUN_SCRIPTS +$BACKUP_CMD +if [[ $? == 0 ]]; then + curl https://hc-ping.com/$HEALTH_UUID +else + curl https://hc-ping.com/$HEALTH_UUID/fail +fi diff --git a/env.sample.sh b/env.sample.sh new file mode 100644 index 0000000..7da32bd --- /dev/null +++ b/env.sample.sh @@ -0,0 +1,9 @@ +NAME=Backup Name +BACKUP_DIR=/dir/to/back/up +BACKUP_PARAMS="" +HEALTHCHECK_UUID="healthchecks.io uuid" + +export AWS_ACCESS_KEY_ID= +export AWS_SECRET_ACCESS_KEY= +export RESTIC_REPOSITORY="s3:https://repo.tld/bucket/sub-bucket" +export RESTIC_PASSWORD=V3RYSecuRepaSsWord diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..302b910 --- /dev/null +++ b/init.sh @@ -0,0 +1,3 @@ +#!/bin/bash +source env.sh +restic init diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..73479ad --- /dev/null +++ b/readme.md @@ -0,0 +1,3 @@ +A set of scripts to simplify running restic backup jobs via cron. + +Also includes curl resquests to healthchecks.io service for monitoring purposes diff --git a/snapshots.sh b/snapshots.sh new file mode 100644 index 0000000..2d31386 --- /dev/null +++ b/snapshots.sh @@ -0,0 +1,3 @@ +#!/bin/bash +source env.sh +restic snapshots