bin: add extensive borg integration
This commit is contained in:
parent
64afb74b0a
commit
d8c7616eb0
|
@ -1,11 +1,13 @@
|
|||
#!/bin/sh
|
||||
# Backup root filesystem with borg
|
||||
case "$1" in
|
||||
(-n) run="arg-test"; shift;;
|
||||
(-*) 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")"
|
||||
name="::$(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 \
|
||||
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"
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh -e
|
||||
# Simple backup with borg
|
||||
test $# -eq 0 && borg list --format "{barchive:40} {time}{NL}" && exit 0
|
||||
test "$1" = "-n" && run=arg-test && shift
|
||||
case "$1" in (*_) prefix=$1; shift;; esac
|
||||
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" "$@"
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
export DATA="$(test -d $HOME/daten && echo $HOME/daten || echo $HOME/data)"
|
||||
export MUSIC="$DATA/music"
|
||||
|
||||
export BORG_REPO="/mnt/backup/borg"
|
||||
export BORG_PASSCOMMAND='pass services/borg/backup'
|
||||
|
||||
# xdg
|
||||
export XDG_DATA_HOME="$HOME/.local/share"
|
||||
export XDG_STATE_HOME="$HOME/.local/state"
|
||||
|
|
Loading…
Reference in New Issue