aboutsummaryrefslogtreecommitdiff
path: root/tw/services/restic.scm
diff options
context:
space:
mode:
authorTimo Wilken2023-11-02 23:57:18 +0100
committerTimo Wilken2023-11-02 23:57:18 +0100
commit16a694a210a6c20bb2d904e9468732dfdf11d6d5 (patch)
tree1f776d57368f60eda70dbde6179e9d1a64da8960 /tw/services/restic.scm
parent6d2872c94c20dd6c4b0e296163aaffebc786ba23 (diff)
Cache restic repos depending on repository type
It makes more sense never to use a cache for local repositories (since they're on local disk already), but to use it (and keep it clean) for remote REST repositories.
Diffstat (limited to 'tw/services/restic.scm')
-rw-r--r--tw/services/restic.scm14
1 files changed, 12 insertions, 2 deletions
diff --git a/tw/services/restic.scm b/tw/services/restic.scm
index 7c912251..7deea24a 100644
--- a/tw/services/restic.scm
+++ b/tw/services/restic.scm
@@ -55,7 +55,15 @@ password-store entry.")
(or (restic-local-repository? thing)
(restic-rest-repository? thing)))
+(define (restic-cache-policy repository)
+ "Choose a cache policy restic argument for operating on REPOSITORY."
+ (cond
+ ((restic-local-repository? repository) "--no-cache")
+ ((restic-rest-repository? repository) "--cleanup-cache")
+ (else (error "Unknown repository type" repository))))
+
(define (set-restic-variables repository password-source)
+ "Return a gexp that sets the right environment variables to access REPOSITORY."
(define repo-string
(match repository
(($ <restic-local-repository> path)
@@ -247,7 +255,8 @@ true."
#~(begin
#$(set-restic-variables repo password)
(execl #$(file-append restic "/bin/restic")
- "restic" "forget" "--no-cache"
+ "restic" "forget"
+ #$(restic-cache-policy repo)
#$@(arg-with-value "--prune" prune?)
#$@(arg-with-value "--host" snapshot-host)
#$@(arg-with-value "--path" snapshot-paths)
@@ -317,7 +326,8 @@ must be given. Leading @code{~/} are replaced with @code{$HOME}.")
path))
#$(set-restic-variables repo password)
(apply execl #$(file-append restic "/bin/restic")
- "restic" "backup" "--cleanup-cache"
+ "restic" "backup"
+ #$(restic-cache-policy repo)
#$@(append-map (lambda (tag) (list "--tag" tag)) tags)
(map replace-home '#$paths)))))))
(map cronjob configs))