GNU bug report logs - #76169
home: Add home-restic-backup service.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: paul <goodoldpaul@HIDDEN>; dated Mon, 10 Feb 2025 00:06:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.
Added blocking bug(s) 72803 Request was from paul <goodoldpaul@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 76169 <at> debbugs.gnu.org:


Received: (at 76169) by debbugs.gnu.org; 10 Feb 2025 00:07:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 09 19:07:32 2025
Received: from localhost ([127.0.0.1]:46934 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1thHKl-0008Ho-H7
	for submit <at> debbugs.gnu.org; Sun, 09 Feb 2025 19:07:32 -0500
Received: from confino.investici.org ([93.190.126.19]:20075)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <goodoldpaul@HIDDEN>)
 id 1thHKh-0008Ha-Aa
 for 76169 <at> debbugs.gnu.org; Sun, 09 Feb 2025 19:07:28 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org;
 s=stigmate; t=1739146045;
 bh=eC4oukd9SZzDOVNKbcRFycPV70B3SPnn2nMr5ZFASZQ=;
 h=From:To:Cc:Subject:Date:From;
 b=qnZZvxl/Ao4sBAJ6v/sCvoWhvm/qCBh1/EKbkIgxUYUA9C64eGklS3tsA1f/6S5nJ
 8TiJOrR3fB93ZLOmnA3CbOV5u3y4Y/Ir71/bzMuOVfBy2ASMuNS+f6O7abgdLbkZWy
 9P16WElGoRMxvzddILtgJ/3Zs8pwMedhN57Dhhts=
Received: from mx1.investici.org (unknown [127.0.0.1])
 by confino.investici.org (Postfix) with ESMTP id 4YrlJF5s0Wz110V;
 Mon, 10 Feb 2025 00:07:25 +0000 (UTC)
Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19])
 (Authenticated sender: goodoldpaul@HIDDEN) by localhost (Postfix) with
 ESMTPSA id 4YrlJF4spBz110G; Mon, 10 Feb 2025 00:07:25 +0000 (UTC)
From: Giacomo Leidi <goodoldpaul@HIDDEN>
To: 76169 <at> debbugs.gnu.org
Subject: [PATCH] home: Add home-restic-backup service.
Date: Mon, 10 Feb 2025 01:06:42 +0100
Message-ID: <d2544a068e6751d3983e0a58950cde674cadae13.1739146002.git.goodoldpaul@HIDDEN>
X-Mailer: git-send-email 2.48.1
MIME-Version: 1.0
X-Debbugs-Cc: Andrew Tropin <andrew@HIDDEN>, Janneke Nieuwenhuizen <janneke@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Tanguy Le Carrour <tanguy@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 76169
Cc: Giacomo Leidi <goodoldpaul@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

* gnu/home/services/backup.scm: New file.
* gnu/local.mk: Add this.
* doc/guix.texi: Document this.

Change-Id: Ied1c0a5756b715fba176a0e42ea154246089e6be
---
 doc/guix.texi                |  49 ++++++++++++++++
 gnu/home/services/backup.scm | 107 +++++++++++++++++++++++++++++++++++
 gnu/local.mk                 |   1 +
 3 files changed, 157 insertions(+)
 create mode 100644 gnu/home/services/backup.scm

diff --git a/doc/guix.texi b/doc/guix.texi
index 86582fb4785..f8ad6769306 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -462,6 +462,7 @@ Top
 * GPG: GNU Privacy Guard.       Setting up GPG and related tools.
 * Desktop: Desktop Home Services.  Services for graphical environments.
 * Guix: Guix Home Services.     Services for Guix.
+* Backup: Backup Home Services.   Services for backing up User's files.
 * Fonts: Fonts Home Services.   Services for managing User's fonts.
 * Sound: Sound Home Services.   Dealing with audio.
 * Mail: Mail Home Services.     Services for managing mail.
@@ -46729,6 +46730,7 @@ Home Services
 * GPG: GNU Privacy Guard.       Setting up GPG and related tools.
 * Desktop: Desktop Home Services.  Services for graphical environments.
 * Guix: Guix Home Services.     Services for Guix.
+* Backup: Backup Home Services.   Services for backing up User's files.
 * Fonts: Fonts Home Services.   Services for managing User's fonts.
 * Sound: Sound Home Services.   Dealing with audio.
 * Mail: Mail Home Services.     Services for managing mail.
@@ -48275,6 +48277,53 @@ Guix Home Services
 @end lisp
 @end defvar
 
+@node Backup Home Services
+@subsection Backup Home Services
+
+The @code{(gnu services backup)} module offers services for backing up
+file system trees.  For now, it provides the @code{restic-backup-service-type}.
+
+With @code{restic-backup-service-type}, you can periodically back up
+directories and files with @uref{https://restic.net/, Restic}, which
+supports end-to-end encryption and deduplication.  Consider the
+following configuration:
+
+@lisp
+(use-modules (gnu services backup)      ;for 'restic-backup-job' and 'restic-backup-configuration'
+             (gnu home services backup) ;for 'restic-backup-service-type'
+             (gnu packages sync)        ;for 'rclone'
+             @dots{})
+
+(home-environment
+
+  (packages (list rclone    ;for use by restic
+                  @dots{}))
+  (services
+    (list
+      (service home-restic-backup-service-type
+               (restic-backup-configuration
+                 (jobs
+                   (list (restic-backup-job
+                           (name "remote-ftp")
+                           (repository "rclone:remote-ftp:backup/restic")
+                           (password-file "/home/alice/.restic")
+                           ;; Every day at 23.
+                           (schedule "0 23 * * *")
+                           (files '("/home/alice/.restic"
+                                    "/home/alice/.config/rclone"
+                                    "/home/alice/Pictures"))))))))))
+@end lisp
+
+You can refer to @pxref{Miscellaneous Services,
+@code{restic-backup-service-type}} for details about
+@code{restic-backup-configuration} and @code{restic-job-configuration}.
+The only difference is that the @code{home-restic-backup-service-type}
+will ignore the @code{user} and @code{group} field of
+@code{restic-job-configuration}.
+
+It will also install the @command{restic-guix} package to the user's Home
+profile.
+
 @node Fonts Home Services
 @subsection Fonts Home Services
 
diff --git a/gnu/home/services/backup.scm b/gnu/home/services/backup.scm
new file mode 100644
index 00000000000..421737eef74
--- /dev/null
+++ b/gnu/home/services/backup.scm
@@ -0,0 +1,107 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Giacomo Leidi <goodoldpaul@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu home services backup)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (gnu services)
+  #:use-module (gnu services backup)
+  #:use-module (gnu services configuration)
+  #:use-module (gnu home services)
+  #:use-module (gnu home services shepherd)
+  #:use-module (srfi srfi-1)
+  #:export (home-restic-backup-service-type))
+
+(define (home-restic-job-log-file job)
+  (let ((name (restic-backup-job-name job))
+        (log-file (restic-backup-job-log-file job)))
+    (and (maybe-value-set? log-file) log-file)))
+
+(define (restic-backup-job->home-shepherd-service config)
+  (let ((schedule (restic-backup-job-schedule config))
+        (name (restic-backup-job-name config))
+        (files (restic-backup-job-files config))
+        (max-duration (restic-backup-job-max-duration config))
+        (wait-for-termination? (restic-backup-job-wait-for-termination? config))
+        (log-file (home-restic-job-log-file config))
+        (requirement (restic-backup-job-requirement config)))
+    (shepherd-service (provision `(,(string->symbol name)))
+                      (requirement
+                       `(,@requirement))
+                      (documentation
+                       "Run @code{restic} backed backups on a regular basis.")
+                      (modules '((shepherd service timer)
+                                 ;;for %user-log-dir
+                                 (shepherd support)))
+                      (start
+                       #~(make-timer-constructor
+                          (if (string? #$schedule)
+                              (cron-string->calendar-event #$schedule)
+                              #$schedule)
+                          (command
+                           (list
+                            "restic-guix" "backup" #$name #$@files))
+                          #:log-file (if (string? #$log-file)
+                                         #$log-file
+                                         (string-append %user-log-dir "/restic-backup/" #$name ".log"))
+                          #:wait-for-termination? #$wait-for-termination?
+                          #:max-duration #$(and (maybe-value-set? max-duration)
+                                                max-duration)))
+                      (stop
+                       #~(make-timer-destructor))
+                      (actions (list (shepherd-action
+                                      (name 'trigger)
+                                      (documentation "Manually trigger a backup,
+without waiting for the scheduled time.")
+                                      (procedure #~trigger-timer)))))))
+
+(define (home-restic-backup-activation config)
+  #~(begin
+      (use-modules (shepherd support))
+      (mkdir-p (string-append %user-log-dir "/restic-backup/"))
+      (for-each
+       (lambda (log-file)
+         (when (string? log-file)
+           (mkdir-p (dirname log-file))))
+       (list #$@(map home-restic-job-log-file
+                     (restic-backup-configuration-jobs config))))))
+
+(define home-restic-backup-service-type
+  (service-type (name 'home-restic-backup)
+                (extensions
+                 (list
+                  (service-extension home-activation-service-type
+                                     home-restic-backup-activation)
+                  (service-extension home-profile-service-type
+                                     restic-backup-service-profile)
+                  (service-extension home-shepherd-service-type
+                                     (lambda (config)
+                                       (map restic-backup-job->home-shepherd-service
+                                            (restic-backup-configuration-jobs
+                                             config))))))
+                (compose concatenate)
+                (extend
+                 (lambda (config jobs)
+                   (restic-backup-configuration
+                    (inherit config)
+                    (jobs (append (restic-backup-configuration-jobs config)
+                                  jobs)))))
+                (default-value (restic-backup-configuration))
+                (description
+                 "This service configures Shepherd timers for running backups
+with restic.")))
diff --git a/gnu/local.mk b/gnu/local.mk
index 117280fc11b..b78c6755f12 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -102,6 +102,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/home.scm					\
   %D%/home/services.scm			\
   %D%/home/services/admin.scm			\
+  %D%/home/services/backup.scm			\
   %D%/home/services/desktop.scm			\
   %D%/home/services/dict.scm			\
   %D%/home/services/dotfiles.scm		\

base-commit: a1fac696c4ef5e20d0412ec22ae6a0d77ea26682
-- 
2.48.1





Information forwarded to andrew@HIDDEN, janneke@HIDDEN, ludo@HIDDEN, maxim.cournoyer@HIDDEN, tanguy@HIDDEN, guix-patches@HIDDEN:
bug#76169; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 10 Feb 2025 00:05:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 09 19:05:29 2025
Received: from localhost ([127.0.0.1]:46920 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1thHIm-0008DM-JN
	for submit <at> debbugs.gnu.org; Sun, 09 Feb 2025 19:05:28 -0500
Received: from lists.gnu.org ([2001:470:142::17]:41894)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <goodoldpaul@HIDDEN>)
 id 1thHIk-0008D1-QG
 for submit <at> debbugs.gnu.org; Sun, 09 Feb 2025 19:05:27 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <goodoldpaul@HIDDEN>)
 id 1thHIY-0002cB-Sa
 for guix-patches@HIDDEN; Sun, 09 Feb 2025 19:05:15 -0500
Received: from confino.investici.org ([2a11:7980:1::2:0])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <goodoldpaul@HIDDEN>)
 id 1thHIW-0005al-Ox
 for guix-patches@HIDDEN; Sun, 09 Feb 2025 19:05:14 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org;
 s=stigmate; t=1739145899;
 bh=xpChnk9gNSBKQT8leBcCgPhrZiP2UAKE//e+nT6GLJU=;
 h=Date:To:From:Subject:From;
 b=ih1G8vYMnFeRGkAJnhkogebFiUqDB8FPkbx5480yF116RdPC42YPD82Ok+84z/h+/
 IgG1Z8Xu+DHR8eib4iBJGOi9qU72JFU3Notz6RaA82l6xBqJryGWEPcJhNd5rmwZIk
 vBjabyOK5Q/8zQQDXNJLlRQeY9FAjU5EETTlhqAk=
Received: from mx1.investici.org (unknown [127.0.0.1])
 by confino.investici.org (Postfix) with ESMTP id 4YrlFR1K1Cz111Q
 for <guix-patches@HIDDEN>; Mon, 10 Feb 2025 00:04:59 +0000 (UTC)
Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19])
 (Authenticated sender: goodoldpaul@HIDDEN) by localhost (Postfix) with
 ESMTPSA id 4YrlFR0nn2z110C
 for <guix-patches@HIDDEN>; Mon, 10 Feb 2025 00:04:59 +0000 (UTC)
Message-ID: <76d82b80-722b-46de-8791-d6a19def8c85@HIDDEN>
Date: Mon, 10 Feb 2025 01:04:58 +0100
MIME-Version: 1.0
User-Agent: Icedove Daily
To: guix-patches@HIDDEN
Content-Language: en-US
From: paul <goodoldpaul@HIDDEN>
Subject: home: Add home-restic-backup service.
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Received-SPF: pass client-ip=2a11:7980:1::2:0;
 envelope-from=goodoldpaul@HIDDEN; helo=confino.investici.org
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

Hi Guix,

I'm sending a patch implementing a Home service for the 
restic-backup-service-type. This patch depends on 
https://issues.guix.gnu.org/72803 .


Thank you for your work!

giacomo





Acknowledgement sent to paul <goodoldpaul@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#76169; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 10 Feb 2025 00:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.