#!/usr/bin/env bash

rsync-cmd() {
  if [[ -n "$1" ]]; then
    dry_run="--dry-run"
  fi

  rsync --verbose \
        --recursive \
        --links \
        --perms \
        --times \
        -D \
        --update \
        --delete-after \
        --compress \
        --human-readable \
        --progress \
        --partial \
        $dry_run \
        "$HOME/Progs" "$HOME/Téléchargements" tria.waarp.org:~/backup
}

#case $1 in
#  "test")
#    rsync-cmd true
#    ;;
#  *)
#    rsync-cmd
#    ;;
#esac

export BORG_REPO="tria.waarp.org:~/borg-backups"
export BORG_PASSCOMMAND='secret-tool lookup borg passphrase'
export BORG_RSH="ssh -i $HOME/.ssh/bca-work-worklaptop"

borg create                         \
    --verbose                       \
    --filter AME                    \
    --list                          \
    --stats                         \
    --show-rc                       \
    --compression zstd,11           \
    "::$(date --iso-8601=minute)"   \
    "$HOME/Progs"                   \
    "$HOME/Téléchargements"

borg prune                          \
    --list                          \
    --show-rc                       \
    --keep-hourly   24              \
    --keep-daily    7               \
    --keep-weekly   4               \
    --keep-monthly  6               \
    --keep-yearly   1

borg compact
borg info
