#! /bin/bash set -e backup_local() { # external program to supply the passphrase: export BORG_PASSCOMMAND="pass show $1" # repo pass first arg # Create Local Backups echo "$(date) -- Creating Local Backups ..." REPOSITORY=$2 # repo vault path second arg shift 2 # consume the first 2 arguments borg create --list --filter AME --stats --compression=lz4 \ --progress \ --exclude '*.pyc' \ --exclude '*/.mypy_cache/' \ --exclude '*/venv/' \ --exclude '*/python*/site-packages/' \ --exclude '*/.tox/' \ --exclude '*/node_modules' \ --exclude '*/dist' \ --exclude '*/.cache' \ --exclude '*/cache' \ --exclude '*/.shadow-cljs' \ --exclude '*/js/compiled' \ --exclude '*/build' \ --exclude '*/target' \ --exclude '*/dist-newstyle' \ --exclude '*/.notmuch' \ --exclude '*/mpd/log' \ --exclude '*/elpa' \ --exclude '*.elc' \ --exclude '*/*.o' \ --exclude '*/guix/*/*.go' \ --exclude '*/guix/*/*.Po' \ --exclude '*/guix/*/*.m4' \ --exclude '*/.local/straight' \ --exclude '*/phd/simulation_data' \ --exclude '*/semantic-roam' \ "$REPOSITORY::{hostname}-{user}-{utcnow:%Y-%m-%dT%H:%M:%S}" \ "$@" # all the dirs to bac # Prune Local Backups echo "$(date) -- Pruning local repository ..." borg prune --verbose --stats --list \ --glob-archives='{hostname}-{user}-*' \ --keep-daily 7 \ --keep-weekly 4 \ --keep-monthly 6 "$REPOSITORY" } BASIC_PATHS=(~/dev/ ~/org/ ~/.mail/ ~/.bogofilter/ ~/Nextcloud/) backup_local Admin/sarah/borg/ingrid ssh://borgbackup@sarah/./repos/ingrid "${BASIC_PATHS[@]}" DISK=/run/media/titan/ext_backup if [ -d "$DISK" ]; then LARGER_PATHS=("$DISK/personal/Pictures/" "$DISK/personal/Libros/" "$DISK/personal/dev/" "$DISK/Archives/") backup_local Admin/sarah/borg/oscar ssh://borgbackup@sarah/./repos/oscar "${LARGER_PATHS[@]}" if ping -c 1 -W 1 192.168.178.128 >/dev/null; then backup_local borgbackup ssh://backup/media/Backup/daily_backup/ "${BASIC_PATHS[@]}" "${LARGER_PATHS[@]}" fi fi