bin: update borg excludes and utilities
This commit is contained in:
parent
b95620e460
commit
01e263f6fa
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
# Backup root filesystem with borg
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
(-n) run="arg-test"; shift;;
|
||||
(--root) shift; root="$1"; name="$(basename "$(realpath "$root")")"; echo $root $name; shift;;
|
||||
(-*) name="${1#-}"; shift;;
|
||||
(*) test $# -gt 0 || cd "$root"; break;;
|
||||
esac
|
||||
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}"
|
||||
sudo chown -R $USER:$USER "$BORG_REPO"
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Backup root filesystem with borg
|
||||
case "$1" in
|
||||
(-n) run="arg-test"; shift;;
|
||||
(-*) name="${1#-}"; shift;;
|
||||
(*) test $# -gt 0 || cd /;;
|
||||
esac
|
||||
name="::$(test -n "$name" && echo "$name" || cat /etc/hostname)_${1:-system}_$(date -u +"%y%m%d")"
|
||||
echo "Backing up as $name"
|
||||
sudo --preserve-env=BORG_REPO ${run:-borg} create --progress --stats \
|
||||
$(echo $DIRS_IGNORE_SAFE -x 'software-challenge/*/build' -x 'emacs/.local' | sed 's|-x \([^ ]\+\)|-e "sh:**/\1"|g') \
|
||||
"$name" $(test $# -eq 0 && echo etc home root || test $# -eq 1 && echo $1) "${@:2}"
|
||||
sudo chown -R $USER:$USER "$BORG_REPO"
|
|
@ -1,16 +1,31 @@
|
|||
#!/bin/sh -e
|
||||
#!/bin/sh
|
||||
# Simple backup with borg
|
||||
if test $# -eq 0
|
||||
then borg list --format "{barchive:40} Created {time}{NL}"
|
||||
exit $?
|
||||
then borg list --format "{barchive:40} Created {time}{NL}"; exit $?
|
||||
fi
|
||||
test "$1" = "-n" && run=arg-test && shift
|
||||
case "$1" in (*_) prefix=$1; shift;; esac
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
(mount) moul backup >/dev/null 2>&1
|
||||
cd /mnt/backup
|
||||
mkdir -p backups
|
||||
borg mount borg backups
|
||||
cd backups
|
||||
"$SHELL"
|
||||
cd ..
|
||||
borg umount backups
|
||||
rm -d backups
|
||||
exit 0;;
|
||||
(ls) borg list --short "::$2" | tree --fromfile . | less -F; exit $?;;
|
||||
(-n) run=arg-test; shift;;
|
||||
(*_) prefix=$1; shift;;
|
||||
(*) break;;
|
||||
esac
|
||||
done
|
||||
name="$(echo "$1" |
|
||||
sed -e 's|/$||' \
|
||||
-e 's|20\([0-9]\{2\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\)|\1\2\3|' \
|
||||
-e 's|\([0-9]\{6\}\)[-_]\(.*\)|\2_\1|' \
|
||||
-e 's|\(\w\+Drive\)|cloud_\L\1|i')"
|
||||
test $# -gt 1 && shift
|
||||
${run:-borg} create --progress --stats "::$prefix$name" "$@"
|
||||
${run:-borg} create --exclude-caches --progress --stats "::$prefix$name" "$@"
|
||||
|
||||
|
|
2
.zshenv
2
.zshenv
|
@ -66,7 +66,7 @@ mkdir -p "$XDG_STATE_HOME/zsh"
|
|||
which nvim >/dev/null && export EDITOR='nvim' || export EDITOR='vim'
|
||||
export LESS="--RAW-CONTROL-CHARS --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)"
|
||||
export DIRS_GENERATED="-x generated -x .gradle -x cmake_build -x dist-newstyle -x node_modules -x __pycache__"
|
||||
export DIRS_IGNORE_SAFE="-x .sync -x .stfolder -x .cache -x *Cache -x .local/cache -x .local/state -x share/JetBrains -x share/Zeal -x share/syncthing -x .cpan -x .cpanm $DIRS_GENERATED"
|
||||
export DIRS_IGNORE_SAFE="-x .sync -x .stfolder -x .cache -x *Cache -x .pyenv -x .local/cache -x share/baloo -x share/cabal -x share/cargo -x share/digikam -x share/JetBrains -x share/syncthing -x share/Steam/ubuntu* -x share/Zeal -x state/gradle -x state/android -x Ferdi/Partitions $DIRS_GENERATED"
|
||||
export DIRS_IGNORE="-x *build -x .git -x .idea -x out -x cache -x Partitions $DIRS_IGNORE_SAFE"
|
||||
# red stderr
|
||||
test -f "/usr/lib/libstderred.so" && export LD_PRELOAD="/usr/lib/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"
|
||||
|
|
Loading…
Reference in New Issue