From: Ralph Ronnquist Date: Mon, 9 Oct 2023 05:29:22 +0000 (+1100) Subject: Add --exclude patterns for configured subtree backups. X-Git-Tag: 0.1~3 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=ba3f605f5f025c199ed81de9747dbc6786c02c8d;p=rrq%2Fbuckap.git Add --exclude patterns for configured subtree backups. --- diff --git a/duplicity-daily b/duplicity-daily index ce659ce..2232092 100755 --- a/duplicity-daily +++ b/duplicity-daily @@ -20,6 +20,17 @@ TARGET="$(grep ^TARGET= -m1 $CONFIG | sed 's/^TARGET=//')" # /opt/other/x=user@host/backup/x SRCS=( $(grep ^/ $CONFIG) ) + +# add --exlude option for any path of $SRCS that extends $1 +excludes() { + local SRC X + for SRC in "${SRCS[@]}" ; do + SRC=${SRC%%=*} + [ "$SRC" = "$1" ] && continue + [ -z "${SRC%$1*}" ] && echo -n " --exclude $SRC" + done +} + for SRC in "${SRCS[@]}" ; do if [ "${SRC#*=}" = "$SRC" ] ; then DST=$TARGET$SRC @@ -28,5 +39,6 @@ for SRC in "${SRCS[@]}" ; do SRC="${SRC%%=*}" fi echo "** Backing up $SRC to $DST" - dupltool ${OPTIONS[*]} $SRC pexpect+scp://$DST + echo dupltool $(excludes "$SRC") ${OPTIONS[*]} $SRC pexpect+scp://$DST + dupltool $(excludes "$SRC") ${OPTIONS[*]} $SRC pexpect+scp://$DST done |& logger -t backup