aboutsummaryrefslogtreecommitdiff
path: root/backup/ad3/backup-cloud
blob: 82b5a1b36fcd8a19b78efe92fbdec78e099f2eb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
set -euo pipefail

if [ "$(id -u)" -ne 0 ]; then
    echo "Run with sudo"
    exit 1
fi

source /root/.restic-env

# Backup LUKS header into a location restic will pick up
cryptsetup luksHeaderBackup /dev/nvme0n1p2 \
    --header-backup-file /root/luks-header-backup.tmp
mv /root/luks-header-backup.tmp /root/luks-header-backup

# Run backup (/ and /boot since /boot is a separate partition)
restic backup / /boot \
    --exclude-file=/home/benj/.mycfg/backup/ad3/restic-exclude.txt \
    --exclude-caches \
    --verbose

# Retention: 4 weekly, 6 monthly, 1 yearly
restic forget \
    --keep-weekly 4 \
    --keep-monthly 6 \
    --keep-yearly 1 \
    --prune

echo ""
echo "=== Latest snapshots ==="
restic snapshots --latest 5