From 0b499bc5a86a6f111e90888ffb18bb64d43138b0 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sat, 15 Jan 2022 22:03:32 +0100 Subject: [PATCH] bin/bag: fix exclusion patterns --- .local/bin/scripts/bag | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.local/bin/scripts/bag b/.local/bin/scripts/bag index 0c1c1ad..6427d6e 100755 --- a/.local/bin/scripts/bag +++ b/.local/bin/scripts/bag @@ -1,8 +1,10 @@ #!/bin/sh # Backup root filesystem with borg +args="--progress --stats" while test $# -gt 0; do case "$1" in (-n) run="arg-test"; shift;; + (--dry-run) args="--dry-run --list"; name=test-$(date +%s); shift;; (--root) shift; root="$1"; name="$(basename "$(realpath "$root")")"; echo $root $name; shift;; (-*) name="${1#-}"; shift;; (*) test $# -gt 0 || cd "$root"; break;; @@ -10,7 +12,8 @@ while test $# -gt 0; do done name="::$(test -n "$name" && echo "$name" || cat /etc/hostname)_${1:-system}_$(date -u +"%y%m%d")" echo "Backing up as $name" -${run:-sudo --preserve-env=BORG_REPO borg} create --exclude-caches --progress --stats \ - $(echo $DIRS_IGNORE_SAFE -x 'software-challenge/**/build' -x state/emacs -x state/go -x .local/lib | sed 's|-x \([^ ]\+\)|-e "sh:**/\1"|g') \ - "$name" $(test $# -eq 0 && echo etc home root || test $# -eq 1 && echo $1) "${@:2}" +${run:-sudo --preserve-env=BORG_REPO borg} --exclude-caches create $args \ + $(echo $DIRS_IGNORE_SAFE -x 'software-challenge/**/build' -x state/emacs -x state/go -x .local/lib | + sed 's|-x \([^ ]\+\)|-e sh:**/\1|g') \ + "$name" $(test $# -eq 0 && echo etc home root || test $# -eq 1 && echo $1) "${@:2}" 2>&1 sudo chown -R $USER:$USER "$BORG_REPO"