#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"

set -x

# shellcheck source=/dev/null
. "${HOME}/.ssh/environment" > /dev/null
BORG_PASSPHRASE="$(cat ~/annex/secret/Borg/passphrase.txt)"
export BORG_PASSPHRASE
R='16686@ch-s010.rsync.net'
export BORG_REMOTE_PATH='borg1'

# env has BORG_PASSPHRASE='...' BORG_REMOTE_PATH='...'
# borg init -e repokey-blake2 $R:desktop-borg

borg create                                  \
     --exclude ~/mbsync/.notmuch/            \
     --exclude ~/gPodder/Downloads           \
     --verbose                               \
     --stats                                 \
     --progress                              \
     --compression lzma,6                    \
     "$R:desktop-borg::{hostname}-{now}-job" \
     ~/Sync/                                 \
     ~/BigSync/                              \
     ~/mbsync/                               \
     ~/archive/                              \
     ~/.mozilla/                             \
     ~/.config/quodlibet/                    \
     ~/gPodder/                              \
     ~/dev/libre/website/                    \
     ~/.elfeed/
     # add folders to be backed up here

# borg prune --keep-last 60 --verbose "$R:desktop-borg"

cd ~/dev/libre/others/borg/
git add .
git commit -m 'JOB: automated update of borg config files after backup.sh'
git push origin master
