dotfiles/.local/bin/scripts/bog

14 lines
467 B
Plaintext
Raw Normal View History

2021-11-25 12:18:57 +00:00
#!/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" "$@"