aboutsummaryrefslogtreecommitdiff
path: root/backup/ad3/backup-cloud
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xbackup/ad3/backup-cloud30
-rw-r--r--backup/ad3/backup-cloud.service10
-rw-r--r--backup/ad3/backup-cloud.timer10
3 files changed, 50 insertions, 0 deletions
diff --git a/backup/ad3/backup-cloud b/backup/ad3/backup-cloud
new file mode 100755
index 0000000..82b5a1b
--- /dev/null
+++ b/backup/ad3/backup-cloud
@@ -0,0 +1,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 \ No newline at end of file
diff --git a/backup/ad3/backup-cloud.service b/backup/ad3/backup-cloud.service
new file mode 100644
index 0000000..472ea75
--- /dev/null
+++ b/backup/ad3/backup-cloud.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Restic backup to Backblaze B2
+Wants=network-online.target
+After=network-online.target
+
+[Service]
+Type=oneshot
+ExecStart=/home/benj/.mycfg/backup/ad3/backup-cloud
+Nice=19
+IOSchedulingClass=idle \ No newline at end of file
diff --git a/backup/ad3/backup-cloud.timer b/backup/ad3/backup-cloud.timer
new file mode 100644
index 0000000..e67bbfd
--- /dev/null
+++ b/backup/ad3/backup-cloud.timer
@@ -0,0 +1,10 @@
+[Unit]
+Description=Weekly cloud backup to B2
+
+[Timer]
+OnCalendar=Sun 02:00
+RandomizedDelaySec=1h
+Persistent=true
+
+[Install]
+WantedBy=timers.target \ No newline at end of file