From b9601cf46a75b373f6b6b902d7ac2be38ab2ffe8 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Tue, 15 Jun 2021 16:45:20 +0200 Subject: borg-family_0.2-1 --- borg-family-0.2/src/sbin/bfenv2 | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 borg-family-0.2/src/sbin/bfenv2 (limited to 'borg-family-0.2/src/sbin/bfenv2') diff --git a/borg-family-0.2/src/sbin/bfenv2 b/borg-family-0.2/src/sbin/bfenv2 new file mode 100755 index 0000000..6e5adeb --- /dev/null +++ b/borg-family-0.2/src/sbin/bfenv2 @@ -0,0 +1,31 @@ +#!/bin/bash +umask 0077 +source /etc/borg-family/confvars +source /etc/borg-family/envvars2 +PATH="/etc/borg-family:$PATH" + +if [ \! -r /etc/borg-family/passphrase2 ]; then + echo "No passphrase2 (repokey) found, creating a new one" >&2 + touch /etc/borg-family/passphrase2 + chmod 600 /etc/borg-family/passphrase2 + pwgen 32 1 >> /etc/borg-family/passphrase2 + ls -l /etc/borg-family/passphrase2 >&2 + echo "You NEED to store it in a password manager to be able to restore backups" >&2 +fi + +if [ \! -r /etc/borg-family/id_rsa_borg ]; then + echo "No SSH key found, creating a new one" >&2 + ssh-keygen -N "" -C "$(id -un)_borg@$(hostname)" -f /etc/borg-family/id_rsa_borg \ + && cat /etc/borg-family/id_rsa_borg.pub +fi + +LANG=C borg init "${borg_init_opts[@]}" 2>&1 | grep -vE '^A repository already exists' >&2 + +if ! borg list > /dev/null; then + echo "Showing BORG_* env variables (see /etc/borg-family/envvars) :" >&2 + env | grep ^BORG_ >&2 + echo "End of BORG_* env variables" >&2 + echo >&2 + echo "Can't access to or check the borg repository, exiting, no backup made" >&2 + exit 1 +fi -- cgit v1.2.3