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)
#: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))))