forked from jortan/borgsnap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bckp_hdlr.sh
58 lines (47 loc) · 1.84 KB
/
bckp_hdlr.sh
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
#!/bin/sh
# cfg_file_hdlr.sh - licensed under GPLv3. See the LICENSE file for additional
# details.
# shellcheck disable=SC3043
if [ -z "${BCKP_HDLR_SOURCED+x}" ]; then
export BCKP_HDLR_SOURCED=1
. ./msg_and_err_hdlr.sh
if [ -z "${LASTFUNC+x}" ]; then
export LASTFUNC=""
fi
if [ -z "${MSG_DEFINED+x}" ]; then
msg() {
LASTFUNC="msg"
printf "WARNING: msg() function called without invoking the debugging.sh script or explicit disabling it!\n"
printf "WARNING: No debug or verbose message outputs available!\n"
return 0
}
export MSG_DEFINED=1
fi
set -u
msg "DEBUG" "sourced bckp_hdlr.sh"
execBackup(){
LASTFUNC="execBackup"
for i in $FS; do
dataset="$i"
localdir="${LOCAL:+$LOCAL/$dataset}"
remotedir="${REMOTESSHCONFIG:+"ssh://"$REMOTESSHCONFIG/$REMOTEDIRPSX/$dataset}"
msg "INFO" "Processing $dataset"
msg "INFO" "remotedir is $remotedir"
if [ "$localdir" != "" ] && [ "$LOCALSKIP" != true ]; then
msg "INFO" "Initializing borg $localdir"
dircreate "" "$LOCAL" "$dataset"
exec_cmd borg init --encryption=repokey "$localdir"
fi
if [ "$remotedir" != "" ]; then
#direxists "$REMOTESSHCONFIG" "$REMOTEDIRPSX" "$dataset"
if direxists "$REMOTESSHCONFIG" "$REMOTEDIRPSX" "$dataset"; then
set -e
msg "INFO" "Initializing remote $remotedir"
dircreate "$REMOTESSHCONFIG" "$REMOTEDIRPSX" "$dataset"
exec_cmd borg init --encryption=repokey --remote-path="${BORGPATH}" "$remotedir"
fi
set -e
fi
done
}
fi