summaryrefslogtreecommitdiff
path: root/borg-family-0.1/src/sbin/bfrun
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2021-01-15 23:17:34 +0100
committerLudovic Pouzenc <ludovic@pouzenc.fr>2021-01-15 23:17:34 +0100
commit1ada10f44e2baf28823156c006c82a076c52f530 (patch)
treec57a5d11efffe6f3a96d02b78765f55a1b6c3889 /borg-family-0.1/src/sbin/bfrun
downloadborg-family-1ada10f44e2baf28823156c006c82a076c52f530.tar.gz
borg-family-1ada10f44e2baf28823156c006c82a076c52f530.tar.bz2
borg-family-1ada10f44e2baf28823156c006c82a076c52f530.zip
borg-family_0.1-1
Diffstat (limited to 'borg-family-0.1/src/sbin/bfrun')
-rwxr-xr-xborg-family-0.1/src/sbin/bfrun29
1 files changed, 29 insertions, 0 deletions
diff --git a/borg-family-0.1/src/sbin/bfrun b/borg-family-0.1/src/sbin/bfrun
new file mode 100755
index 0000000..c02187a
--- /dev/null
+++ b/borg-family-0.1/src/sbin/bfrun
@@ -0,0 +1,29 @@
+#!/bin/bash
+source bfenv
+bfwhat | while IFS=' ' read -r mpe dev; do
+ mp=$(echo -e "$mpe") # mp: interpret escapings that may be present in /proc/mounts (\040 for space...)
+ name=${mp// /_}; # name: replace space by underscore
+ name=${mp//\//-}; name=${name/-/} # name: replace slash by dash, remove the leading one
+ if [[ "$mp $name $dev" =~ "--" || "$mp $name $dev" =~ ".." || "$mp $name $dev" =~ "[|&;()<>]" ]]; then
+ echo "Skipping $mpe because of shell unsafe characters" >&2
+ continue
+ fi
+
+ comment=$(blkid -- "$dev")
+ if [ -r "/etc/borg-family/excludes.d/$name" ]; then
+ runtime_args=( --comment="$comment" --exclude-from="/etc/borg-family/excludes.d/$name" )
+ else
+ runtime_args=( --comment="$comment" )
+ fi
+
+ bfhooks before "$name" && \
+ borg create "${runtime_args[@]}" "${borg_create_opts[@]}" "::{hostname}-$name-{now:%Y-%m-%d}" "$mp"
+ rc1=$?
+ bfhooks after "$name"
+ rc2=$?
+ if [ "$rc1" -ne 0 -o "$rc2" -ne 0 ]; then
+ echo "Errors during $name backup, return codes $rc1 (bfhook before && borg create) and $rc2 (bfhook after)" >&2
+ else
+ [ "x$quiet" == "x1" ] || echo "Success for $name backup"
+ fi
+done