aboutsummaryrefslogtreecommitdiff
path: root/borg-backup
blob: b9572f64cd730f8ca9774e8f7bb3879baa387805 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
set -euo pipefail

REPO="borg@192.168.33.5:/tank/backups/borg"
NAME="home-$(date +%F_%H-%M)"
SRC="/home/lukasz"

export BORG_RSH="ssh -p 57385 -i $HOME/.ssh/sacrum.key -o IdentitiesOnly=yes"

LOGDIR="$HOME/.local/state/borg"
mkdir -p "$LOGDIR"
LOGFILE="$LOGDIR/backup-$(date +%F).log"

# Show progress if stdout is a terminal (manual run)
ARGS=(--compression lz4 --exclude-from "$HOME/.config/borg/excludes")
if [ -t 1 ]; then
  ARGS+=(--progress --list --stats)
else
  ARGS+=(--stats)
fi

# Always log; show on screen when interactive
borg create "${ARGS[@]}" "$REPO"::"$NAME" "$SRC" 2>&1 | tee -a "$LOGFILE"