2022-01-13 19:52:03 +00:00
|
|
|
#!/bin/sh
|
2021-11-25 12:18:57 +00:00
|
|
|
# Simple backup with borg
|
2021-12-02 22:33:22 +00:00
|
|
|
if test $# -eq 0
|
2022-01-13 19:52:03 +00:00
|
|
|
then borg list --format "{barchive:40} Created {time}{NL}"; exit $?
|
2021-12-02 22:33:22 +00:00
|
|
|
fi
|
2022-01-13 19:52:03 +00:00
|
|
|
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
|
2021-11-25 12:18:57 +00:00
|
|
|
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
|
2022-01-13 19:52:03 +00:00
|
|
|
${run:-borg} create --exclude-caches --progress --stats "::$prefix$name" "$@"
|
2021-11-25 12:18:57 +00:00
|
|
|
|