aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-05-23 14:49:45 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-05-23 14:49:45 -0300
commit1407b63399c437dd4a32ab2fd3ec548395f85fe8 (patch)
tree37e7bde5a67f04fc7101e6452ec09f0fb1b1d381
parentab1896ad3e9f685ae96b09410936df63f8642dfa (diff)
downloadpuppet-backup-1407b63399c437dd4a32ab2fd3ec548395f85fe8.tar.gz
puppet-backup-1407b63399c437dd4a32ab2fd3ec548395f85fe8.tar.bz2
Borg: custom keyfile support
-rw-r--r--manifests/borg.pp1
-rw-r--r--templates/borg.sh.erb9
2 files changed, 10 insertions, 0 deletions
diff --git a/manifests/borg.pp b/manifests/borg.pp
index e027984..eff0f74 100644
--- a/manifests/borg.pp
+++ b/manifests/borg.pp
@@ -7,6 +7,7 @@ define backup::borg(
$user = $::hostname,
$host = "${title}.${::domain}",
$encryption = 'repokey',
+ $keyfile = '',
$order = 95,
$periodic_check = absent,
$password,
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