aboutsummaryrefslogtreecommitdiff
path: root/bin/bust-hostfs
blob: 4b62e3d61182618675be754f20ff7ad40630968c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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 "$@"