From 3c2ee5e5383e4deac893489b4920297f4a4cb7b6 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Sat, 20 May 2023 13:32:32 +0200 Subject: Rename `restic-backup-repository' to allow for cleanup repos --- tw/home/lap.scm | 2 +- tw/services/restic.scm | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'tw') diff --git a/tw/home/lap.scm b/tw/home/lap.scm index 235a3de2..44f345da 100644 --- a/tw/home/lap.scm +++ b/tw/home/lap.scm @@ -128,7 +128,7 @@ `(("RESTIC_PASSWORD_COMMAND" . "pass computers/vin/restic-repos/laptop"))) (service home-restic-backup-service-type - (list (restic-repository + (list (restic-backup-repository (schedule #~"0 */2 * * *") (paths '(;; important user data "~/audiobooks" diff --git a/tw/services/restic.scm b/tw/services/restic.scm index d088e8ba..18c501a9 100644 --- a/tw/services/restic.scm +++ b/tw/services/restic.scm @@ -14,8 +14,7 @@ #:export (restic-server-service-type restic-server-configuration home-restic-backup-service-type - home-restic-backup-configuration - restic-repository)) + restic-backup-repository)) (define-public %restic-user "restic") (define-public %restic-group "restic") @@ -129,10 +128,11 @@ private restic repos.") (define (nonempty-list-of-strings? thing) (and (pair? thing) (list-of-strings? thing))) -(define-configuration/no-serialization restic-repository +(define-configuration/no-serialization restic-backup-repository (schedule gexp "An mcron schedule, specified as a gexp -(@pxref{G-Expressions}). String, list or lambda syntax is fine -(@pxref{Syntax, mcron job specifications,, mcron, GNU@tie{}mcron}).") +(@pxref{G-Expressions}), to use for the backup job. String, list or lambda +syntax is fine (@pxref{Syntax, mcron job specifications,, mcron, +GNU@tie{}mcron}).") (paths nonempty-list-of-strings "List of paths to back up. At least one must be given. Leading @code{~/} are replaced with @code{$HOME}.") (url-command string "Run this command (inside @code{sh -c}) to obtain the @@ -144,7 +144,7 @@ passwords in @code{rest:} URLs.") (define (restic-backup-cronjobs repositories) (define (cronjob repo) - #~(job #$(restic-repository-schedule repo) + #~(job #$(restic-backup-repository-schedule repo) #$(program-file "restic-backup-command" #~(begin @@ -156,15 +156,15 @@ passwords in @code{rest:} URLs.") (string-replace path (getenv "HOME") 0 1) path)) (setenv "RESTIC_PASSWORD_COMMAND" - '#$(restic-repository-password-command repo)) - (let ((pipe (open-pipe '#$(restic-repository-url-command repo) OPEN_READ))) + '#$(restic-backup-repository-password-command repo)) + (let ((pipe (open-pipe '#$(restic-backup-repository-url-command repo) OPEN_READ))) (setenv "RESTIC_REPOSITORY" (string-trim-right (get-string-all pipe) #\newline)) (close-pipe pipe)) - (apply execl #$(file-append (restic-repository-restic repo) "/bin/restic") - "restic" "backup" + (apply execl #$(file-append (restic-backup-repository-restic repo) "/bin/restic") + "restic" "backup" "--cleanup-cache" #$@(append-map (lambda (tag) (list "--tag" tag)) - (restic-repository-tags repo)) - (map replace-home '#$(restic-repository-paths repo))))))) + (restic-backup-repository-tags repo)) + (map replace-home '#$(restic-backup-repository-paths repo))))))) (map cronjob repositories)) (define home-restic-backup-service-type @@ -175,4 +175,4 @@ passwords in @code{rest:} URLs.") (compose concatenate) (extend append) (default-value '()) - (description "Run scheduled backup jobs to the specified repos."))) + (description "Back up local directories on a schedule."))) -- cgit v1.2.3