dotfiles/.local/bin/scripts/barg

12 lines
510 B
Bash
Executable File

#!/bin/sh
# Backup root filesystem with borg
case "$1" in
(-*) name="${1#-}"; shift;;
(*) test $# -gt 0 || cd /;;
esac
name="/mnt/backup/borg::$(test -n "$name" && echo "$name" || cat /etc/hostname)-${1:-system}-$(date -u +"%y%m%d")"
echo "Backing up as $name"
sudo borg create --progress --stats \
$(echo $IGNOREDIRS_PURE -x 'software-challenge/*/build' -x 'emacs/.local' | sed 's|-x \([^ ]\+\)|-e "*/\1" -e \1|g') \
"$name" $(test $# -eq 0 && echo etc home root || test $# -eq 1 && echo $1) "${@:2}"