homelab/roles/lander/files/lander.backup.sh

13 lines
336 B
Bash
Raw Normal View History

2024-01-10 13:51:51 +01:00
#!/usr/bin/env bash
data_dir='/mnt/data1/lander'
snapshot_dir="${data_dir}.snapshot"
# Read-only snapshot for atomic backup
btrfs subvolume snapshot -r "$data_dir" "$snapshot_dir" || exit $?
/usr/local/bin/restic backup "$snapshot_dir"
2024-01-10 13:51:51 +01:00
# Always remove snapshot subvolume, even if restic fails
btrfs subvolume delete "$snapshot_dir"