operating-systems: buer: shepherd-services: Guard snapshot command with a unless file-exists?, to avoid trying to snapshot /home twice in a day

main
Luis Guilherme Coelho 2024-11-28 09:14:26 -03:00
parent 31f4e5e991
commit e514737fe3
No known key found for this signature in database
GPG Key ID: 1F2E76ACE3F531C8
1 changed files with 7 additions and 5 deletions

View File

@ -43,11 +43,13 @@ next calendar event.")))
#:hours '(8 14 20) #:hours '(8 14 20)
#:minutes '(0)) #:minutes '(0))
(lambda () (lambda ()
(let ((btrfs "/run/current-system/profile/bin/btrfs") (let* ((btrfs "/run/current-system/profile/bin/btrfs")
(date (strftime "%Y-%m-%d" (localtime (current-time))))) (date (strftime "%Y-%m-%d" (localtime (current-time))))
(spawn-shell-command (snapshot (string-append "/snapshots/home/" date)))
(string-append btrfs " subvolume snapshot" (unless (file-exists? snapshot)
" /home /snapshots/home/" date)))))) (spawn-shell-command
(string-join
`(btrfs "subvolume snapshot /home" snapshot))))))))
(stop #~(make-timer-destructor)) (stop #~(make-timer-destructor))
(actions (list timer-trigger-action)))) (actions (list timer-trigger-action))))