]> gitweb.fluxo.info Git - puppet-backup.git/commitdiff
Borg: custom keyfile support
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 23 May 2018 17:49:45 +0000 (14:49 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 23 May 2018 17:49:45 +0000 (14:49 -0300)
manifests/borg.pp
templates/borg.sh.erb

index e0279843577c98c3533fec554cf138e39460f568..eff0f74b85d39773d9865cde7dda0f5c47c8aee1 100644 (file)
@@ -7,6 +7,7 @@ define backup::borg(
     $user           = $::hostname,
     $host           = "${title}.${::domain}",
     $encryption     = 'repokey',
+    $keyfile        = '',
     $order          = 95,
     $periodic_check = absent,
     $password,
index dfb3d1fdc7f6df83d270505b00caaf3cc8f43250..c32d63e9ea6db82428cb5b9e1de6939667f4f228 100644 (file)
@@ -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