removed help, made static arguments and case for them

This commit is contained in:
2021-08-17 21:14:40 -04:00
parent cac6a07cf0
commit c81fa4f585

View File

@@ -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