Subject: [bug#75045] [PATCH] services: restic-backup: Implement as a Shepherd timer.

From: Ludovic Courtès <[email-masked]>
Date: Tue, 24 Dec 2024 11:40:19 +0100

Hi Giacomo,

Giacomo Leidi <[email-masked]> skribis:

> This patch implements restic backup with Shepherd services.  It is
> supposed not to break any existing setup.
>
> * gnu/services/backup.scm (restic-backup-job): Add Shepherd
> configuration options;
> (restic-backup-job->mcron-job): Replace with...;
> (restic-job-log-file): New procedure;
> (restic-backup-job->shepherd-service): New procedure;
> (restic-backup-activation): New procedure;
> (restic-backup-service-type): Replace mcron with Shepherd extension and add
> activation extension hook.
> * doc/guix.texi: Document it.
>
> Change-Id: I66de3b6a1cb6177f9e4ee0c2acf3013ecbcdd338

Woo, nice!

As mentioned in <https://issues.guix.gnu.org/74860>, I think we should
postpone a little bit since these new features won’t work for people who
haven’t rebooted into Shepherd 1.0, and they’ll get possibly confusing
messages when reconfiguring.

How we should postpone, I’m not sure.  The conservative approach would
be to wait until after the next Guix release, but that doesn’t sound
reasonable…  One month after the Shepherd upgrade, which would be
Jan. 9th?  It’s common for servers to have much longer uptimes though,
plus there’s end-of-year vacation here.

> +  (log-file
> +   (maybe-string)
> +   "The file system path to the log file for this job.  By default the file will
> +have the name of the job and be under @code{/var/log/restic-backup}.")

Rather @file, with the “.log” suffix too, if I’m not mistaken.

> +  (max-duration
> +   (maybe-number)
> +   "The maximum duration in seconds that a job may last.  Past
> +@code{max-duration} seconds, the job will forcefully terminated.")

s/will/is/

> +    (shepherd-service (provision `(,(string->symbol
> +                                     (string-append name "-job"))))

I would tend to not add the “-job” suffix, but that’s a matter of taste!

> +                          (command
> +                           (list
> +                            (string-append #+bash-minimal "/bin/bash")
> +                            "-l" "-c"
> +                            (string-append "restic-guix backup " #$name))

Why go through bash?  Would it be possible to execute ‘restic-guix’
directly?

>                  (description
> -                 "This service configures @code{mcron} jobs for running backups
> +                 "This service configures @code{Shepherd} timers for running backups
>  with @code{restic}.")))

You can drop @code here.