#!/bin/sh
# Backup my relevant data in my backup drive
# 
# 2025 (C) Pablo
# Free use of this software is granted under the terms of the GPL-3.0 License

set -x # debug mode

date="$(date '+%Y-%m-%d')"

borg create                                                                \
  --verbose                                                                \
  --filter AME                                                             \
  --list                                                                   \
  --stats                                                                  \
  --show-rc                                                                \
  --compression lz4                                                        \
  --exclude-caches                                                         \
  --exclude-from "$HOME/.local/share/excludefile"                          \
  "/run/media/pablo/Seagate Backup Plus Drive/Backups/::$(hostname)-$date" \
  "$HOME/.ssh"                                                             \
  "$HOME/docx"                                                             \
  "$HOME/picx"                                                             \
  "$HOME/TODO.md"                                                          \
  "$HOME/.config"                                                          \
  "$HOME/.local/share"                                                     \
  "$TEXMFHOME"                                                             \
  "$HOME/.local/bin"                                                       \

# continue even if there are warnings: warnings return 1 but errors return 2
[ $? -eq 2 ] && exit 1
set -e # exit on errors

gpg --export --armor pablo-escobar@riseup.net \
  > '/run/media/pablo/Seagate Backup Plus Drive/pablo.asc' 

gpg --export-secret-keys --armor pablo-escobar@riseup.net \
  > '/run/media/pablo/Seagate Backup Plus Drive/pablo-secret.asc' 

gpg --export-ownertrust \
  > '/run/media/pablo/Seagate Backup Plus Drive/trustdb.txt' 
