You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"${NODES_TO_BACK_UP[@]}"|| err "local borg create failed with [$?]"
74
+
75
+
borg prune -v --list \
76
+
"$BORG_LOCAL_REPO" \
77
+
--prefix "$PREFIX_WITH_HOSTNAME" \
78
+
$BORG_PRUNE_OPTS|| err "local borg prune failed with [$?]"
79
+
}
80
+
81
+
82
+
backup_remote() {
83
+
# duplicate to remote location: (http://borgbackup.readthedocs.io/en/latest/faq.html#can-i-copy-or-synchronize-my-repo-to-another-location)
84
+
borg create -v --stats \
85
+
$BORG_EXTRA_OPTS \
86
+
$BORG_REMOTE_EXTRA_OPTS \
87
+
"$REMOTE"::"$ARCHIVE_NAME" \
88
+
"${NODES_TO_BACK_UP[@]}"|| err "remote borg create failed with [$?]"
89
+
90
+
borg prune -v --list \
91
+
"$REMOTE" \
92
+
--prefix "$PREFIX_WITH_HOSTNAME" \
93
+
$BORG_PRUNE_OPTS|| err "remote borg prune failed with [$?]"
94
+
}
95
+
96
+
66
97
# backup selected data
98
+
# note the borg processes are executed in a sub-shell, so local & remote backup could be
99
+
# run in parallel
67
100
do_backup() {
68
-
localstart_time end_time
101
+
localstarted_pids
69
102
70
-
readonly start_time="$(date +%H:%M:%S)"
103
+
declare -a started_pids=()
71
104
72
-
echo"=> Backup started at [$start_time]"
105
+
log"=> Backup started"
73
106
74
107
dump_db || fail "db dump failed with [$?]"
75
108
expand_nodes_to_back_up
@@ -78,35 +111,19 @@ do_backup() {
78
111
pushd -- "$TMP"|| fail "unable to pushd into [$TMP]"# cd there because files in $TMP are added without full path (to avoid "$TMP_ROOT" prefix in borg repo)
79
112
80
113
if [[ "$REMOTE_ONLY"-ne 1 ]];then
81
-
borg create -v --stats \
82
-
$BORG_EXTRA_OPTS \
83
-
$BORG_LOCAL_EXTRA_OPTS \
84
-
"$BORG_LOCAL_REPO"::"$ARCHIVE_NAME" \
85
-
"${NODES_TO_BACK_UP[@]}"
86
-
87
-
borg prune -v --list \
88
-
"$BORG_LOCAL_REPO" \
89
-
--prefix "$PREFIX_WITH_HOSTNAME" \
90
-
$BORG_PRUNE_OPTS
114
+
backup_local &
115
+
started_pids+=("$!")
91
116
fi
92
117
93
118
if [[ "$LOCAL_ONLY"-ne 1 ]];then
94
-
# duplicate to remote location: (http://borgbackup.readthedocs.io/en/latest/faq.html#can-i-copy-or-synchronize-my-repo-to-another-location)
95
-
borg create -v --stats \
96
-
$BORG_EXTRA_OPTS \
97
-
$BORG_REMOTE_EXTRA_OPTS \
98
-
"$REMOTE"::"$ARCHIVE_NAME" \
99
-
"${NODES_TO_BACK_UP[@]}"
100
-
101
-
borg prune -v --list \
102
-
"$REMOTE" \
103
-
--prefix "$PREFIX_WITH_HOSTNAME" \
104
-
$BORG_PRUNE_OPTS
119
+
backup_remote &
120
+
started_pids+=("$!")
105
121
fi
106
122
123
+
wait"${started_pids[@]}"
124
+
107
125
popd&> /dev/null
108
-
readonly end_time="$(date +%H:%M:%S)"
109
-
echo"=> Backup finished at [$end_time]"
126
+
log "=> Backup finished"
110
127
111
128
return 0
112
129
}
@@ -184,7 +201,7 @@ cleanup() {
184
201
# Entry
185
202
# ================
186
203
trap -- 'cleanup; exit' EXIT HUP INT QUIT PIPE TERM
0 commit comments