From e514737fe36dd3209f3909513f0fa24ca3975022 Mon Sep 17 00:00:00 2001 From: Luis Guilherme Coelho Date: Thu, 28 Nov 2024 09:14:26 -0300 Subject: [PATCH] operating-systems: buer: shepherd-services: Guard snapshot command with a unless file-exists?, to avoid trying to snapshot /home twice in a day --- operating-systems/buer/shepherd-services.scm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/operating-systems/buer/shepherd-services.scm b/operating-systems/buer/shepherd-services.scm index a31da28..bec1ece 100644 --- a/operating-systems/buer/shepherd-services.scm +++ b/operating-systems/buer/shepherd-services.scm @@ -43,11 +43,13 @@ next calendar event."))) #:hours '(8 14 20) #:minutes '(0)) (lambda () - (let ((btrfs "/run/current-system/profile/bin/btrfs") - (date (strftime "%Y-%m-%d" (localtime (current-time))))) - (spawn-shell-command - (string-append btrfs " subvolume snapshot" - " /home /snapshots/home/" date)))))) + (let* ((btrfs "/run/current-system/profile/bin/btrfs") + (date (strftime "%Y-%m-%d" (localtime (current-time)))) + (snapshot (string-append "/snapshots/home/" date))) + (unless (file-exists? snapshot) + (spawn-shell-command + (string-join + `(btrfs "subvolume snapshot /home" snapshot)))))))) (stop #~(make-timer-destructor)) (actions (list timer-trigger-action))))