aboutsummaryrefslogtreecommitdiff
path: root/bin/bust-hostfs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bust-hostfs')
-rwxr-xr-xbin/bust-hostfs40
1 files changed, 40 insertions, 0 deletions
diff --git a/bin/bust-hostfs b/bin/bust-hostfs
new file mode 100755
index 0000000..4b62e3d
--- /dev/null
+++ b/bin/bust-hostfs
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+
+main() {
+ while read -r repo proto
+ do
+ mkbackup "$repo" "$proto"
+ done < /etc/bust/repositories
+}
+
+mkbackup() {
+ local repo="$1" ; shift
+ local proto="$1" ; shift
+
+ local borg
+
+ export BORG_PASSPHRASE="$(passphrase)"
+
+ borg=(
+ "borg" "create"
+ "--one-file-system"
+ "--remote-path" "$proto"
+ "$repo/hostfs::$(date -u "+%FT%TZ")"
+ )
+
+ while read -r path
+ do
+ borg+=("$path")
+ done < /etc/bust/filesystem.d/paths
+
+ printf "> %s\n" "${borg[*]}"
+
+ if [[ -n $BUST_DRYRUN ]]
+ then
+ return 0
+ fi
+
+ ${borg[@]}
+}
+
+main "$@"