From 0958e3c43ae0bc8c0c7b201b65a63474c0faedb5 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Thu, 2 Nov 2023 20:35:05 +0100 Subject: Fix Guix' restic's apparent lack of support for --keep-X=-1 --- tw/services/restic.scm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tw') diff --git a/tw/services/restic.scm b/tw/services/restic.scm index 68bab007..7c912251 100644 --- a/tw/services/restic.scm +++ b/tw/services/restic.scm @@ -228,6 +228,14 @@ true." (($ _ _ _ _ path) path))) #\/)) + (define (norm-keep number) + ;; Guix' restic version doesn't seem to support "--keep-X=-1" to keep all + ;; snapshots in the specified interval, so pass a very high number instead. + (if (and (number? number) + (= -1 number)) + 1000000 + number)) + (define (cronjob config) (match-record config (schedule repo password restic user snapshot-host snapshot-paths prune? @@ -245,11 +253,11 @@ true." #$@(arg-with-value "--path" snapshot-paths) #$@(arg-with-value "--keep-within" keep-within) #$@(arg-with-value "--keep-last" keep-last) - #$@(arg-with-value "--keep-hourly" keep-hourly) - #$@(arg-with-value "--keep-daily" keep-daily) - #$@(arg-with-value "--keep-weekly" keep-weekly) - #$@(arg-with-value "--keep-monthly" keep-monthly) - #$@(arg-with-value "--keep-yearly" keep-yearly)))) + #$@(arg-with-value "--keep-hourly" (norm-keep keep-hourly)) + #$@(arg-with-value "--keep-daily" (norm-keep keep-daily)) + #$@(arg-with-value "--keep-weekly" (norm-keep keep-weekly)) + #$@(arg-with-value "--keep-monthly" (norm-keep keep-monthly)) + #$@(arg-with-value "--keep-yearly" (norm-keep keep-yearly))))) #$@(if (maybe-value-set? user) (list #:user user) '())))) (map cronjob configs)) -- cgit v1.2.3