blob: 572b30c3215e8d3a94a64f303bfd007e9e67c519 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/usr/bin/env bash
## :bocs:
## :section: X
## :heading: authors
##
## - Patrick Spek `<p.spek@tyil.nl>`
readonly BUST_BIN_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
main() {
while getopts ":lnh" OPT; do
case "$OPT" in
l)
PATH="$BUST_BIN_DIR:$PATH"
;;
n)
export BUST_DRYRUN=1
;;
h)
usage
exit 0
;;
*)
usage
;;
esac
done
shift $(( OPTIND - 1 ))
local script="$1" ; shift
# Make sure there is a backup script given
if [[ -z "$script" ]]
then
usage
exit 1
fi
# Check if the desired backup script exists
if ! command -v "bust-$script" > /dev/null
then
usage
exit 1
fi
export BUST_SCRIPT="$script"
export -f passphrase
exec "bust-$script" "$@"
}
## :bocs:
## :section: 1
## :heading: synopsis
##
## ```
## bust -h
## bust [-l] database-psql
## bust [-l] filesystem
## ```
## :bocs:
## :section: 1
## :heading: description
##
## **bust** is a set of Bash scripts to call Borg to create backups of your
## data.
## :bocs:
## :section: 1
## :heading: examples
##
## NYI
## :bocs:
## :section: 1
## :heading: see also
##
## - bust-filesystem
## - bust-database-psql
usage() {
cat <<EOF
Usage:
$0 -h
$0 [-l] database-psql
$0 [-l] filesystem
Options:
-l Prepend the directory containing the bust program to your PATH.
Useful for testing purposes.
Create borg-based backups with a single command.
EOF
}
passphrase() {
[[ -n $BORG_PASSPHRASE ]] && printf "%s" "$BORG_PASSPHRASE" && return
[[ -x /etc/bust/passphrase ]] && /etc/bust/passphrase && return
[[ -f /etc/bust/passphrase ]] && cat /etc/bust/passphrase && return
}
main "$@"
|