From 1407b63399c437dd4a32ab2fd3ec548395f85fe8 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 23 May 2018 14:49:45 -0300 Subject: Borg: custom keyfile support --- templates/borg.sh.erb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'templates/borg.sh.erb') diff --git a/templates/borg.sh.erb b/templates/borg.sh.erb index dfb3d1f..c32d63e 100644 --- a/templates/borg.sh.erb +++ b/templates/borg.sh.erb @@ -14,6 +14,15 @@ export BORG_PASSPHRASE='<%= @password %>' # or this to ask an external program to supply the passphrase: #export BORG_PASSCOMMAND='pass show backup' +# Custom keyfile support +if [ "<%= @encryption %>" == "keyfile" ] && [ ! -z "<%= @keyfile %>" ]; then + if [ ! -e "<%= @keyfile %>" ]; then + fatal "Keyfile not found: <%= @keyfile %>. Please create it manually." + fi + + export BORG_KEY_FILE="/root/.borg/hydra/key" +fi + # some helpers and error handling: #info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; } trap 'info $( date ) Backup interrupted >&2; exit 2' INT TERM -- cgit v1.2.3