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

BACKUP_TAG="${1-cron}"

# 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'

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

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