From 5ea25529b9811b4e3eb57a3560ac6b69788e9877 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Mon, 8 Mar 2021 00:08:22 -0700 Subject: [PATCH] feature(BACKUP): add SSH port customization - borgSSHPort variable in details file - read and appended to RSH connection string - default to standard port 22 Closes github #9 --- backup/backup.details | 9 ++++++--- backup/backup.sh | 11 ++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/backup/backup.details b/backup/backup.details index abef7ed..e6bc894 100644 --- a/backup/backup.details +++ b/backup/backup.details @@ -18,14 +18,17 @@ # base configuration directory for borg, all borg parameters use this directory # as their 'root'. I recommend setups with this being "/var/borgbackup", the # default is "$HOME" or "~$USER" in that order. If you're unsure, try "$HOME" -borgBaseDir="/var/borgbackup" +borgBaseDir = "/var/borgbackup" + +# SSH port on which your borg server listens. By default, this is port 22. +borgSSHPort = 22 # full path to the SSH key used to connect to your remote backup server -borgSSHKey="/var/borgbackup/private.key" +borgSSHKey = "/var/borgbackup/private.key" # connection string to access the borg repo on your remote backup server # this is usually in the form user@servername.tld:repoName/ -borgConnectRepo="jdoe123@borg.server.net:mailcow/" +borgConnectRepo = "jdoe123@borg.server.net:mailcow/" # password to access repo # this was set when the repo was initialized and, while optional, is HIGHLY diff --git a/backup/backup.sh b/backup/backup.sh index 6af7500..f3e2fa3 100755 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -529,7 +529,16 @@ elif [ ! -f "${borgSSHKey}" ]; then fi printf "%sdetails:borgSSHKey %s-- %s[OK]%s\n" \ "$magenta" "$norm" "$ok" "$norm" >> "$logFile" -export BORG_RSH="ssh -i ${borgSSHKey}" +## check SSH port +if [ -z "${borgSSHPort}" ]; then + borgSSHPort=22 + printf "%sdetails:borgSSHPort %s-- %s[DEFAULT]%s\n" \ + "$magenta" "$norm" "$ok" "$norm" >> "$logFile" +else + printf "%sdetails:borgSSHPort %s-- %s[CUSTOM]%s\n" \ + "$magenta" "$norm" "$ok" "$norm" >> "$logFile" +fi +export BORG_RSH="ssh -i ${borgSSHKey} -p ${borgSSHPort}" ## check borg repo connect string if [ -z "${borgConnectRepo}" ]; then