dotfiles/.local/bin/scripts/bog

17 lines
484 B
Bash
Executable File

#!/bin/sh -e
# Simple backup with borg
if test $# -eq 0
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
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" "$@"