summaryrefslogtreecommitdiff
path: root/tw/services/restic.scm
diff options
context:
space:
mode:
authorTimo Wilken2023-06-03 23:59:17 +0200
committerTimo Wilken2023-06-03 23:59:17 +0200
commit1bb96ebf8b93b856de64d7bb02c8fb47254932cb (patch)
treec7159da346a3179333c72d36248b2a4620758c22 /tw/services/restic.scm
parentbb169097d97e9ff20e56d7d1a950866c6b25f007 (diff)
Indent *-file functions more conveniently
Files with potentially long or complex contents shouldn't be indented quite as far.
Diffstat (limited to 'tw/services/restic.scm')
-rw-r--r--tw/services/restic.scm79
1 files changed, 39 insertions, 40 deletions
diff --git a/tw/services/restic.scm b/tw/services/restic.scm
index 62764750..f3ad6f82 100644
--- a/tw/services/restic.scm
+++ b/tw/services/restic.scm
@@ -151,26 +151,26 @@ true."
(define (cronjob repo)
#~(job #$(restic-cleanup-repository-schedule repo)
#$(program-file
- ;; Make cron commands for different repos easier to distinguish.
- (format #f "restic-cleanup-~a-command"
- (string-trim-right (basename (restic-cleanup-repository-url repo)) #\/))
- #~(begin
- ;; `setgid' first, while we're still root.
- (setgid (group:gid (getgr #$%restic-group)))
- (setuid (passwd:uid (getpw #$%restic-user)))
- (setenv "RESTIC_REPOSITORY" '#$(restic-cleanup-repository-url repo))
- (setenv "RESTIC_PASSWORD_FILE" '#$(restic-cleanup-repository-password-file repo))
- (execl #$(file-append (restic-cleanup-repository-restic repo) "/bin/restic")
- "restic" "forget" "--no-cache"
- #$@(arg-with-value "--prune" (restic-cleanup-repository-prune? repo))
- #$@(arg-with-value "--path" (restic-cleanup-repository-snapshot-paths repo))
- #$@(arg-with-value "--keep-within" (restic-cleanup-repository-keep-within repo))
- #$@(arg-with-value "--keep-last" (restic-cleanup-repository-keep-last repo))
- #$@(arg-with-value "--keep-hourly" (restic-cleanup-repository-keep-hourly repo))
- #$@(arg-with-value "--keep-daily" (restic-cleanup-repository-keep-daily repo))
- #$@(arg-with-value "--keep-weekly" (restic-cleanup-repository-keep-weekly repo))
- #$@(arg-with-value "--keep-monthly" (restic-cleanup-repository-keep-monthly repo))
- #$@(arg-with-value "--keep-yearly" (restic-cleanup-repository-keep-yearly repo)))))))
+ ;; Make cron commands for different repos easier to distinguish.
+ (format #f "restic-cleanup-~a-command"
+ (string-trim-right (basename (restic-cleanup-repository-url repo)) #\/))
+ #~(begin
+ ;; `setgid' first, while we're still root.
+ (setgid (group:gid (getgr #$%restic-group)))
+ (setuid (passwd:uid (getpw #$%restic-user)))
+ (setenv "RESTIC_REPOSITORY" '#$(restic-cleanup-repository-url repo))
+ (setenv "RESTIC_PASSWORD_FILE" '#$(restic-cleanup-repository-password-file repo))
+ (execl #$(file-append (restic-cleanup-repository-restic repo) "/bin/restic")
+ "restic" "forget" "--no-cache"
+ #$@(arg-with-value "--prune" (restic-cleanup-repository-prune? repo))
+ #$@(arg-with-value "--path" (restic-cleanup-repository-snapshot-paths repo))
+ #$@(arg-with-value "--keep-within" (restic-cleanup-repository-keep-within repo))
+ #$@(arg-with-value "--keep-last" (restic-cleanup-repository-keep-last repo))
+ #$@(arg-with-value "--keep-hourly" (restic-cleanup-repository-keep-hourly repo))
+ #$@(arg-with-value "--keep-daily" (restic-cleanup-repository-keep-daily repo))
+ #$@(arg-with-value "--keep-weekly" (restic-cleanup-repository-keep-weekly repo))
+ #$@(arg-with-value "--keep-monthly" (restic-cleanup-repository-keep-monthly repo))
+ #$@(arg-with-value "--keep-yearly" (restic-cleanup-repository-keep-yearly repo)))))))
(map cronjob repositories))
@@ -207,26 +207,25 @@ passwords in @code{rest:} URLs.")
(define (restic-backup-cronjobs repositories)
(define (cronjob repo)
#~(job #$(restic-backup-repository-schedule repo)
- #$(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))
- (setenv "RESTIC_PASSWORD_COMMAND"
- '#$(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-backup-repository-restic repo) "/bin/restic")
- "restic" "backup" "--cleanup-cache"
- #$@(append-map (lambda (tag) (list "--tag" tag))
- (restic-backup-repository-tags repo))
- (map replace-home '#$(restic-backup-repository-paths repo)))))))
+ #$(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))
+ (setenv "RESTIC_PASSWORD_COMMAND"
+ '#$(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-backup-repository-restic repo) "/bin/restic")
+ "restic" "backup" "--cleanup-cache"
+ #$@(append-map (lambda (tag) (list "--tag" tag))
+ (restic-backup-repository-tags repo))
+ (map replace-home '#$(restic-backup-repository-paths repo)))))))
(map cronjob repositories))
(define home-restic-backup-service-type