From 6812d052650b62a090852101bad99dd48a964c19 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Wed, 1 Nov 2023 23:10:16 +0100 Subject: Generalise Restic declarations * rename confusingly named restic-*-repository variables to restic-scheduled-* * generalise repository handling, allowing local and REST repositories both as backup and cleanup targets * generalise password handling, allowing passwords from pass or from files for backup, for cleanup and as part of a REST URL --- tw/system/vin.scm | 64 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 23 deletions(-) (limited to 'tw/system') diff --git a/tw/system/vin.scm b/tw/system/vin.scm index 6a773a58..d05a493b 100644 --- a/tw/system/vin.scm +++ b/tw/system/vin.scm @@ -66,19 +66,27 @@ (prometheus-auth? #f))) (service restic-cleanup-service-type - (list (restic-cleanup-repository + (list (restic-scheduled-cleanup ;; Laptop backups run at "0 */2 * * *". (schedule #~"0 5 * * *") - (url "/var/backups/restic/timo/laptop") - (password-file "/etc/restic/timo-laptop") + (repo (restic-local-repository + (path "/var/backups/restic/timo/laptop"))) + (password (restic-password-source + (type 'file) + (name "/etc/restic/timo-laptop"))) + (user "restic") (keep-within "14d") (keep-weekly 52) (keep-monthly -1)) - (restic-cleanup-repository + (restic-scheduled-cleanup (schedule #~"0 5 * * *") - (url "/var/backups/restic/timo/sync") - (password-file "/etc/restic/timo-sync") + (repo (restic-local-repository + (path "/var/backups/restic/timo/sync"))) + (password (restic-password-source + (type 'file) + (name "/etc/restic/timo-sync"))) + (user "restic") (keep-within "14d") (keep-weekly 52) (keep-monthly -1)) @@ -88,33 +96,43 @@ ;; these, so create the repo on the server before pushing to it. ;; Restic doesn't automatically upgrade the repo version. ;; - ;; Phone backups run "hourly" (modulo Android's throttling of - ;; the Restic app), but the underlying data changes at most once - ;; a day, so use `keep-daily' instead of `keep-within'. - - (restic-cleanup-repository - (schedule #~"0 3 * * *") - (url "/var/backups/restic/timo/phone") - (password-file "/etc/restic/timo-phone") + ;; Phone backups run "daily" (modulo Android's throttling of + ;; the Restic app; usually between midnight and 2am), so use + ;; `keep-daily' instead of `keep-within' to discard duplicates. + + (restic-scheduled-cleanup + (schedule #~"0 4 * * *") + (repo (restic-local-repository + (path "/var/backups/restic/timo/phone"))) + (password (restic-password-source + (type 'file) + (name "/etc/restic/timo-phone"))) + (user "restic") (snapshot-paths '("/storage/FF37-F8E6/SignalBackup")) ;; We only really care about the last signal backup, but guard ;; against accidental deletion by keeping more. (keep-daily 3)) - (restic-cleanup-repository + (restic-scheduled-cleanup (schedule #~"0 4 * * *") - (url "/var/backups/restic/timo/phone") - (password-file "/etc/restic/timo-phone") + (repo (restic-local-repository + (path "/var/backups/restic/timo/phone"))) + (password (restic-password-source + (type 'file) + (name "/etc/restic/timo-phone"))) + (user "restic") (snapshot-paths '("/storage/emulated/0/Backups")) (keep-daily 14) (keep-monthly -1)) - (restic-cleanup-repository - ;; OAndBackupX/NeoBackup backups can run until the early-ish - ;; morning; cleanup once they're all done and pushed. - (schedule #~"0 11 * * *") - (url "/var/backups/restic/timo/phone") - (password-file "/etc/restic/timo-phone") + (restic-scheduled-cleanup + (schedule #~"0 4 * * *") + (repo (restic-local-repository + (path "/var/backups/restic/timo/phone"))) + (password (restic-password-source + (type 'file) + (name "/etc/restic/timo-phone"))) + (user "restic") (snapshot-paths '("/storage/FF37-F8E6/OAndBackupX")) (keep-daily 14) (keep-monthly -1)))) -- cgit v1.2.3