From c81fa4f585f03e52844df7c3b7d7528af18f6d22 Mon Sep 17 00:00:00 2001 From: John Gaunt Date: Tue, 17 Aug 2021 21:14:40 -0400 Subject: [PATCH] removed help, made static arguments and case for them --- restic.sh | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/restic.sh b/restic.sh index 9bea44b..7371479 100644 --- a/restic.sh +++ b/restic.sh @@ -1,32 +1,31 @@ #!/bin/sh -Help() -{ - # Display Help - echo "Runs a restic backup." - echo - echo "Syntax: restic.sh [-h|--hostname] [-c|--copyOffsite]" - echo "options:" - echo "-h, --hostname Hostname, used to select correct dirs to backup (Requried)." - echo "-c, --copyOffsite Used to copy a hostname's backup repo files to other computers." - echo -} - - +# restic.sh [Hostname] [-c|--copyOffsite] +# the hostname must be entered and be the first argument and is required +# the -c is optional and must be the second arguments LOCKFILE="/tmp/restic.lock" LOGFILE="/var/log/restic/restic_$(date +%Y%m%d-%H%M%S).log" LATEST_RESTIC_VERSION="0.12.1" -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 +case $1 in + + "GauntBitwarden") + BACKUP_DIRS="/etc /opt/bitwarden /var/spool/cron" + ;; + + "GauntNAS") + BACKUP_DIRS="/etc/version /data /root --exclude=/root/.cache" + export RESTIC_REPOSITORY="/mnt/data/backups/restic" + ;; + + *) + echo "Error: Hostname, $1, didn't match any known matches." + exit 1 + ;; +esac # make log directory