aboutsummaryrefslogtreecommitdiff
path: root/tw/services/restic.scm
diff options
context:
space:
mode:
authorTimo Wilken2024-08-25 19:11:54 +0200
committerTimo Wilken2024-08-25 19:11:54 +0200
commite862b7a5b28de96c426b2c105718519caf204039 (patch)
tree49afb888c1ffdc5bea3ef2822475090736c53661 /tw/services/restic.scm
parent161dc84fce2c2de603d0b867d07e9a412897e51c (diff)
Send mail output for some mcron jobs
For mcron jobs that only output text when they fail, mail that output.
Diffstat (limited to 'tw/services/restic.scm')
-rw-r--r--tw/services/restic.scm68
1 files changed, 35 insertions, 33 deletions
diff --git a/tw/services/restic.scm b/tw/services/restic.scm
index f23da013..2ea8c084 100644
--- a/tw/services/restic.scm
+++ b/tw/services/restic.scm
@@ -249,24 +249,25 @@ true."
prune? keep-last keep-hourly keep-daily keep-weekly
keep-monthly keep-yearly keep-within)
#~(job #$schedule
- #$(program-file
- ;; Make cron commands for different repos easier to distinguish.
- (string-append "restic-cleanup-" (repo-path-basename repo) "-command")
- #~(begin
- #$(set-restic-variables repo password)
- (execl #$(file-append restic "/bin/restic")
- "restic" "forget"
- #$(restic-cache-policy repo)
- #$@(arg-with-value "--prune" prune?)
- #$@(arg-with-value "--host" snapshot-host)
- #$@(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" (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)))))
+ (with-mail-out
+ #$(program-file
+ ;; Make cron commands for different repos easier to distinguish.
+ (string-append "restic-cleanup-" (repo-path-basename repo) "-command")
+ #~(begin
+ #$(set-restic-variables repo password)
+ (execl #$(file-append restic "/bin/restic")
+ "restic" "forget" "--quiet"
+ #$(restic-cache-policy repo)
+ #$@(arg-with-value "--prune" prune?)
+ #$@(arg-with-value "--host" snapshot-host)
+ #$@(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" (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))
@@ -314,21 +315,22 @@ must be given. Leading @code{~/} are replaced with @code{$HOME}.")
(define (cronjob config)
(match-record config <restic-scheduled-backup> (schedule paths repo password tags restic)
#~(job #$schedule
- #$(program-file "restic-backup-command"
- #~(begin
- (use-modules (ice-9 popen)
- (ice-9 textual-ports)
- (srfi srfi-1))
- (define (replace-home path)
- (if (string-prefix? "~/" path)
- (string-replace path (getenv "HOME") 0 1)
- path))
- #$(set-restic-variables repo password)
- (apply execl #$(file-append restic "/bin/restic")
- "restic" "backup"
- #$(restic-cache-policy repo)
- #$@(append-map (lambda (tag) (list "--tag" tag)) tags)
- (map replace-home '#$paths)))))))
+ (with-mail-out
+ #$(program-file "restic-backup-command"
+ #~(begin
+ (use-modules (ice-9 popen)
+ (ice-9 textual-ports)
+ (srfi srfi-1))
+ (define (replace-home path)
+ (if (string-prefix? "~/" path)
+ (string-replace path (getenv "HOME") 0 1)
+ path))
+ #$(set-restic-variables repo password)
+ (apply execl #$(file-append restic "/bin/restic")
+ "restic" "backup" "--quiet"
+ #$(restic-cache-policy repo)
+ #$@(append-map (lambda (tag) (list "--tag" tag)) tags)
+ (map replace-home '#$paths))))))))
(map cronjob configs))
(define home-restic-backup-service-type