2021-11-07 03:05:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Backup root filesystem with borg
|
2021-11-09 04:37:07 +00:00
|
|
|
case "$1" in
|
2021-11-25 12:18:57 +00:00
|
|
|
(-n) run="arg-test"; shift;;
|
2021-11-09 04:37:07 +00:00
|
|
|
(-*) name="${1#-}"; shift;;
|
|
|
|
(*) test $# -gt 0 || cd /;;
|
|
|
|
esac
|
2021-11-25 12:18:57 +00:00
|
|
|
name="::$(test -n "$name" && echo "$name" || cat /etc/hostname)_${1:-system}_$(date -u +"%y%m%d")"
|
2021-11-09 04:37:07 +00:00
|
|
|
echo "Backing up as $name"
|
2021-11-25 12:18:57 +00:00
|
|
|
sudo --preserve-env=BORG_REPO ${run:-borg} create --progress --stats \
|
2021-11-19 11:01:04 +00:00
|
|
|
$(echo $DIRS_IGNORE_SAFE -x 'software-challenge/*/build' -x 'emacs/.local' | sed 's|-x \([^ ]\+\)|-e "sh:**/\1"|g') \
|
2021-11-09 04:37:07 +00:00
|
|
|
"$name" $(test $# -eq 0 && echo etc home root || test $# -eq 1 && echo $1) "${@:2}"
|
2021-11-25 12:18:57 +00:00
|
|
|
sudo chown -R $USER:$USER "$BORG_REPO"
|