From b771147456c355dd22f124c131e13ec954d0aadb Mon Sep 17 00:00:00 2001 From: Bryan Date: Fri, 11 Sep 2020 08:18:57 -0600 Subject: [PATCH] Change hostname to SYSTEM_NAME user variable as part of repo name, adde beginning --- src/borgwrapper | 4 ++-- src/config.example | 6 ++++-- src/install | 13 +++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 src/install diff --git a/src/borgwrapper b/src/borgwrapper index b1f3166..40d4798 100755 --- a/src/borgwrapper +++ b/src/borgwrapper @@ -64,7 +64,7 @@ borg_backup () { ${BORG} create \ "${BORG_CREATE_ARGS[@]}" \ - "${BORG_REPO}"::"{hostname}-$(date -u +'%Y%m%dT%H%M%SZ')" \ + "${BORG_REPO}"::"${SYSTEM_NAME}-$(date -u +'%Y-%m-%dT%H-%M-%SZ')" \ "${PATHS[@]}" \ "${EXCLUDE_CMD[@]}" } @@ -85,7 +85,7 @@ borg_prune () { ${BORG} prune \ "${BORG_PRUNE_ARGS[@]}" \ - --prefix "{hostname}-" \ + --prefix "${SYSTEM_NAME}-" \ --keep-hourly=${KEEP_HOURLY:-0} \ --keep-daily=${KEEP_DAILY:-0} \ --keep-weekly=${KEEP_WEEKLY:-0} \ diff --git a/src/config.example b/src/config.example index 052d37c..1e07367 100644 --- a/src/config.example +++ b/src/config.example @@ -1,8 +1,10 @@ #BORG="/usr/bin/borg" -BORG_REPO="@:/srv/borg/$(hostname -f)" + +SYSTEM_NAME="name-of-computer" +BORG_REPO="@:/srv/borg/${SYSTEM_NAME}" # If using a non-standard SSH port ssh:// have to be specified (per borg v1.0.9) -#BORG_REPO="ssh://@:/srv/borg/$(hostname -f)" +#BORG_REPO="ssh://@:/srv/borg/${SYSTEM_NAME}" BORG_PASSPHRASE="longandcomplexpassphrase" PATHS=( "/etc" diff --git a/src/install b/src/install new file mode 100644 index 0000000..bd79067 --- /dev/null +++ b/src/install @@ -0,0 +1,13 @@ +#! /bin/bash + +cp -i ./borgwrapper /usr/local/bin/borgwrapper +chown root. /usr/local/bin/borgwrapper +chmod 750 /usr/local/bin/borgwrapper + +if [! -d /etc/borgwrapper/ ]; then + mkdir /etc/borgwrapper/config +fi + +cp -i config /etc/borgwrapper/config +chown root. /etc/borgwrapper/config +chmod 600 /etc/borgwrapper/config