From a4b1959d4d8db46abeb2cdddbf85b6b502546aed Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Fri, 16 Feb 2024 20:32:54 +0100 Subject: Clean up backups from new machines --- tw/system/vin.scm | 129 +++++++++++++++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 65 deletions(-) (limited to 'tw/system') diff --git a/tw/system/vin.scm b/tw/system/vin.scm index dc5bc756..6a72026d 100644 --- a/tw/system/vin.scm +++ b/tw/system/vin.scm @@ -69,76 +69,75 @@ (prometheus-auth? #f))) (service restic-cleanup-service-type - (list (restic-scheduled-cleanup - ;; Laptop backups run at "0 */2 * * *". - (schedule #~"0 5 * * *") - (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)) + (cons* + ;; Phone backups run with a new version of restic, which creates + ;; v2 repos by default. Guix' older restic version can't read + ;; these, so create the repo on the server before pushing to it. + ;; Restic doesn't automatically upgrade the repo version. + ;; + ;; 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 5 * * *") - (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)) + (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)) - ;; Phone backups run with a new version of restic, which creates - ;; v2 repos by default. Guix' older restic version can't read - ;; these, so create the repo on the server before pushing to it. - ;; Restic doesn't automatically upgrade the repo version. - ;; - ;; 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/emulated/0/Backups")) + (keep-daily 14) + (keep-monthly -1)) - (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-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)) - (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/emulated/0/Backups")) - (keep-daily 14) - (keep-monthly -1)) + ;; Computer backups run at "0 */2 * * *". + ;; Backups of sync folders run at "X */2 * * *" on computers, + ;; for various values of X (to avoid conflicts), and nightly + ;; around midnight on the phone. + (map (lambda (repo) + (let ((path (car repo)) + (password-file (cdr repo))) + (restic-scheduled-cleanup + (schedule #~"0 5 * * *") + (repo (restic-local-repository (path path))) + (password (restic-password-source + (type 'file) + (name password-file))) + (user "restic") + (keep-within "14d") + (keep-weekly 52) + (keep-monthly -1)))) - (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)))) + '(("/var/backups/restic/timo/laptop" . "/etc/restic/timo-laptop") + ("/var/backups/restic/timo/framework" . "/etc/restic/timo-framework") + ("/var/backups/restic/timo/battleship" . "/etc/restic/timo-battleship") + ("/var/backups/restic/timo/sync" . "/etc/restic/timo-sync"))))) (service secrets-service-type (secrets-configuration -- cgit v1.2.3