#!/bin/bash

SOURCE_DIRS=("/home/liph/Documents" "/home/liph/Pictures" "/home/liph/Downloads")
REPO_DIR="/home/liph/borg-repo"
BORG_PASSPHRASE="1ChagearC"

export BORG_PASSPHRASE

for SOURCE_DIR in "${SOURCE_DIRS[@]}"; do
  ARCHIVE_NAME="{hostname}-{user}-{now}"

  echo "Starting backup of ${SOURCE_DIR}..."
  borg create --stats --progress \
    "${REPO_DIR}::${ARCHIVE_NAME}" \
    "${SOURCE_DIR}"

  if [ $? -eq 0 ]; then
    echo "Backup of ${SOURCE_DIR} completed successfully!"
  else
    echo "Backup of ${SOURCE_DIR} failed!"
  fi
done

echo "Pruning old backups..."
borg prune --stats --progress \
  --keep-daily=7 \
  --keep-weekly=4 \
  --keep-monthly=6 \
  "${REPO_DIR}"

echo "Backup and pruning completed!"

