From patchwork Thu Jun 20 03:44:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 65503 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 76C5327BBF0; Thu, 20 Jun 2024 04:46:41 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 0786627BBE2 for ; Thu, 20 Jun 2024 04:46:39 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK8kL-0006tM-EU; Wed, 19 Jun 2024 23:46:01 -0400 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 ) id 1sK8kJ-0006sq-NE for guix-patches@gnu.org; Wed, 19 Jun 2024 23:45:59 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK8kJ-0007Sg-7S; Wed, 19 Jun 2024 23:45:59 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sK8kM-0006Zk-H0; Wed, 19 Jun 2024 23:46:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71661] [PATCH v2 1/5] services: backup: Support bootstrapping an initial restic backup Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Thu, 20 Jun 2024 03:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71661 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71661@debbugs.gnu.org, 71639@debbugs.gnu.org Cc: Richard Sent , Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-To: guix-patches@gnu.org, 71639@debbugs.gnu.org X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by submit@debbugs.gnu.org id=B.171885512425097 (code B ref -1); Thu, 20 Jun 2024 03:46:02 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jun 2024 03:45:24 +0000 Received: from localhost ([127.0.0.1]:41516 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK8jk-0006Wi-Bn for submit@debbugs.gnu.org; Wed, 19 Jun 2024 23:45:24 -0400 Received: from lists.gnu.org ([209.51.188.17]:55410) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK8ji-0006WV-II for submit@debbugs.gnu.org; Wed, 19 Jun 2024 23:45:23 -0400 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 ) id 1sK8je-0006go-MB for guix-patches@gnu.org; Wed, 19 Jun 2024 23:45:18 -0400 Received: from mail-108-mta184.mxroute.com ([136.175.108.184]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK8jc-0007Dl-Ju for guix-patches@gnu.org; Wed, 19 Jun 2024 23:45:18 -0400 Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta184.mxroute.com (ZoneMTA) with ESMTPSA id 19033bf912d00017a3.002 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 20 Jun 2024 03:45:10 +0000 X-Zone-Loop: 85195fd8e0fffd1ff96d061759273e1257b252238144 X-Originating-IP: [136.175.111.3] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XuD2yRINfgfD1RxfCnun9Fbl0b2Udso5fzV/vwuymPk=; b=iH+5ATU6mhxxQ8dDht0NQlabJ9 ofVRq2IeEXVDFkdqrxRWhVp/0uizYuAbS0WNE9OWW417aZ6hY5mCAyVixHRFyEAlBGMtXVjcEL9Oa KLYtc20QwnQ2EOLyzNJ2peWtO4JP+IKVJiyyPSVfXgBtf952Lu77MvFyo6bUCpvSngRpfm/fny/2J NYoqpFzWwuR+e/C4XgIjnB6HFdRu0rLiNi1+YX3WG6SdBNf4KWSp8uMjwnJGzoOOXRPvvppO1I0g6 Pg5LADgSLTN19/sdSvJ0dgynu1kd1SQewZILlzB838Ccvv9IJuFGQvSDlhu8nconbm5iJyAhJ3wwQ PbpglJhw==; From: Richard Sent Date: Wed, 19 Jun 2024 23:44:12 -0400 Message-ID: <93ff43dbc77df724597c7c27ae955581a31a851e.1718854920.git.richard@freakingpenguin.com> In-Reply-To: References: MIME-Version: 1.0 X-Authenticated-Id: richard@freakingpenguin.com Received-SPF: pass client-ip=136.175.108.184; envelope-from=richard@freakingpenguin.com; helo=mail-108-mta184.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/backup.scm: (restic-backup-job): Add init? field. (restic-backup-job-program): Initialize repository if init? is set and repository does not already exist. * doc/guix.texi (Miscellaneous Services): Document it. Change-Id: I71d0cbaac646b9d160e662b69286f229b9a9f64d --- doc/guix.texi | 4 ++++ gnu/services/backup.scm | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 0102fd0fad..63c9cbd1a7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -41353,6 +41353,10 @@ Miscellaneous Services The list of files or directories to be backed up. It must be a list of values that can be lowered to strings. +@item @code{init?} (default: @code{#f}) (type: boolean) +Whether restic-backup-service should check and (if it does not exist) +initialize the repository before running the backup. + @item @code{verbose?} (default: @code{#f}) (type: boolean) Whether to enable verbose output for the current backup job. diff --git a/gnu/services/backup.scm b/gnu/services/backup.scm index 555e9fc959..1279ece88f 100644 --- a/gnu/services/backup.scm +++ b/gnu/services/backup.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2024 Giacomo Leidi +;;; Copyright © 2024 Richard Sent ;;; ;;; This file is part of GNU Guix. ;;; @@ -38,6 +39,7 @@ (define-module (gnu services backup) restic-backup-job-password-file restic-backup-job-schedule restic-backup-job-files + restic-backup-job-init? restic-backup-job-verbose? restic-backup-job-extra-flags @@ -94,6 +96,9 @@ (define-configuration/no-serialization restic-backup-job (verbose? (boolean #f) "Whether to enable verbose output for the current backup job.") + (init? + (boolean #f) + "Whether to attempt to initialize a new repository for automated bootstrap purposes.") (extra-flags (list-of-lowerables '()) "A list of values that are lowered to strings. These will be passed as @@ -118,6 +123,8 @@ (define (restic-backup-job-program config) (restic-backup-job-files config)) (extra-flags (restic-backup-job-extra-flags config)) + (init? + (restic-backup-job-init? config)) (verbose (if (restic-backup-job-verbose? config) '("--verbose") @@ -130,6 +137,18 @@ (define (restic-backup-job-program config) (setenv "RESTIC_PASSWORD" (with-input-from-file #$password-file read-line)) + (when #$init? + ;; Use cat config to check if the repository exists. See + ;; https://github.com/restic/restic/issues/1690 and + ;; https://github.com/NixOS/nixpkgs/pull/307962. + ;; + ;; XXX: restic returns values other than 1 on failure. Check + ;; EXIT_SUCCESS instead of EXIT_FAILURE. + (unless (or (equal? EXIT_SUCCESS (system* #$restic "cat" "config" + "-r" #$repository)) + (equal? EXIT_SUCCESS (system* #$restic "init" + "-r" #$repository))) + (error "Failed to initialize restic repository: " #$repository))) (execlp #$restic #$restic #$@verbose "-r" #$repository #$@extra-flags From patchwork Thu Jun 20 03:44:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 65506 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 70F9727BBEA; Thu, 20 Jun 2024 04:46:56 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id DFC8E27BBE2 for ; Thu, 20 Jun 2024 04:46:53 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK8kP-0006vH-9h; Wed, 19 Jun 2024 23:46:05 -0400 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 ) id 1sK8kN-0006uI-CU for guix-patches@gnu.org; Wed, 19 Jun 2024 23:46:03 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK8kN-0007TF-4K; Wed, 19 Jun 2024 23:46:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sK8kN-0006a1-8a; Wed, 19 Jun 2024 23:46:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71662] [PATCH v2 2/5] services: backup: Add password-command support to restic-service Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Thu, 20 Jun 2024 03:46:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71662 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71662@debbugs.gnu.org, 71639@debbugs.gnu.org Cc: Richard Sent , Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-To: guix-patches@gnu.org, 71639@debbugs.gnu.org X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by submit@debbugs.gnu.org id=B.171885513025136 (code B ref -1); Thu, 20 Jun 2024 03:46:03 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jun 2024 03:45:30 +0000 Received: from localhost ([127.0.0.1]:41523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK8jq-0006XL-9z for submit@debbugs.gnu.org; Wed, 19 Jun 2024 23:45:30 -0400 Received: from lists.gnu.org ([209.51.188.17]:42654) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK8jm-0006Wr-8g for submit@debbugs.gnu.org; Wed, 19 Jun 2024 23:45:26 -0400 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 ) id 1sK8ji-0006hM-AY for guix-patches@gnu.org; Wed, 19 Jun 2024 23:45:22 -0400 Received: from mail-108-mta171.mxroute.com ([136.175.108.171]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK8jg-0007En-Bu for guix-patches@gnu.org; Wed, 19 Jun 2024 23:45:22 -0400 Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta171.mxroute.com (ZoneMTA) with ESMTPSA id 19033bfa8c000017a3.002 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 20 Jun 2024 03:45:16 +0000 X-Zone-Loop: 550f7fdd743d054c550dfccec133bac546296e6d7205 X-Originating-IP: [136.175.111.3] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yyBICg4O1y0fUS6c0vVAsrc8LuuVW7gya8VicEXI1fk=; b=GV2Ok24XjA7ipc7LweVS/akMPJ GnvlF2ytNRNvCP97oj09QU6JHrsJPziR1VEk9mqgEKju/D62kCwzQ9T5IKhD7fhOnF0fYU4+FBhk0 HmpQxEsElwAntkP248iZjJ+r95W1fd7OgIl9SQ4graa9HieTBCtuRU4jNNDtTOZCinYQA35vL+et4 IOp5/LNNeYsWnhLoWi+MH61nvK+5b0QQ+OE3Q6CzQyqPyZCtqa4ZtCpFhhSXrf/GFJBZ4e/umbU6K 68xRsfxPxBj26oCvX8lVLuUDBRrq1DjASBsr+SrxkKe/PDrsBo4wKnPSSnnJN6AVyVAzGgHU2BN2l CsGZVQqA==; From: Richard Sent Date: Wed, 19 Jun 2024 23:44:13 -0400 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Authenticated-Id: richard@freakingpenguin.com Received-SPF: pass client-ip=136.175.108.171; envelope-from=richard@freakingpenguin.com; helo=mail-108-mta171.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/backup.scm (restic-backup-job): Add password-command. (verify-restic-backup-job-configuration): Create. (restic-backup-job-program): Set either RESTIC_PASSWORD or RESTIC_PASSWORD_COMMAND depending on what is configured. * doc/guix.texi (Miscellaneous Services): Document it. Change-Id: Ice9cf85d1ee4485a2737f515c63c969918219df0 --- doc/guix.texi | 7 +++++++ gnu/services/backup.scm | 41 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 63c9cbd1a7..f22d679023 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -41344,6 +41344,13 @@ Miscellaneous Services that will be used to set the @env{RESTIC_PASSWORD} environment variable for the current job. +@item @code{password-command} (type: file-like) +String path or file-like object representing the executable file that +prints password to stdout. If a file-like object is used, it is placed +in the store globally executable and in plain text. The executable +should be designed such that it does not compromise the password if an +unauthorized user runs it. + @item @code{schedule} (type: gexp-or-string) A string or a gexp that will be passed as time specification in the mcron job specification (@pxref{Syntax, mcron job specifications,, diff --git a/gnu/services/backup.scm b/gnu/services/backup.scm index 1279ece88f..fd904bc9a9 100644 --- a/gnu/services/backup.scm +++ b/gnu/services/backup.scm @@ -66,6 +66,9 @@ (define (lowerable? value) (define list-of-lowerables? (list-of lowerable?)) +(define-maybe/no-serialization string) +(define-maybe/no-serialization file-like) + (define-configuration/no-serialization restic-backup-job (restic (package restic) @@ -80,10 +83,16 @@ (define-configuration/no-serialization restic-backup-job (string) "The restic repository target of this job.") (password-file - (string) + (maybe-string) "Name of the password file, readable by the configured @code{user}, that will be used to set the @code{RESTIC_PASSWORD} environment variable for the current job.") + (password-command + (maybe-file-like) + "An executable file who's path is stored in @code{RESTIC_PASSWORD_COMMAND}. +When run, the file writes the password to standard output. Due to the nature +of the store this command will be globally executable and should have external +protections to ensure unauthorized users cannot retrieve the password.") (schedule (gexp-or-string) "A string or a gexp that will be passed as time specification in the mcron @@ -104,6 +113,14 @@ (define-configuration/no-serialization restic-backup-job "A list of values that are lowered to strings. These will be passed as command-line arguments to the current job @command{restic backup} invokation.")) +(define (verify-restic-backup-job-configuration config) + (unless (or (maybe-value-set? (restic-backup-job-password-file config)) + (maybe-value-set? (restic-backup-job-password-command config))) + (error "either password-file or password-command must be configured.")) + (when (and (maybe-value-set? (restic-backup-job-password-file config)) + (maybe-value-set? (restic-backup-job-password-command config))) + (error "password-file and password-command can not be configured simultaneously."))) + (define list-of-restic-backup-jobs? (list-of restic-backup-job?)) @@ -113,12 +130,21 @@ (define-configuration/no-serialization restic-backup-configuration "The list of backup jobs for the current system.")) (define (restic-backup-job-program config) + (define (maybe-value-or-false maybe) + (if (maybe-value-set? maybe) + maybe + #f)) + + (verify-restic-backup-job-configuration config) + (let ((restic (file-append (restic-backup-job-restic config) "/bin/restic")) (repository (restic-backup-job-repository config)) (password-file - (restic-backup-job-password-file config)) + (maybe-value-or-false (restic-backup-job-password-file config))) + (password-command + (maybe-value-or-false (restic-backup-job-password-command config))) (files (restic-backup-job-files config)) (extra-flags @@ -134,9 +160,14 @@ (define (restic-backup-job-program config) #~(begin (use-modules (ice-9 popen) (ice-9 rdelim)) - (setenv "RESTIC_PASSWORD" - (with-input-from-file #$password-file read-line)) - + (or (and=> #$password-file (lambda (x) + (setenv "RESTIC_PASSWORD" + (with-input-from-file x read-line)))) + (and=> #$password-command (lambda (x) + (setenv "RESTIC_PASSWORD_COMMAND" x))) + ;; Have a backup error message in case + ;; verify-restic-backup-job-configuration is messed with + (error "Neither password-file or password-command set")) (when #$init? ;; Use cat config to check if the repository exists. See ;; https://github.com/restic/restic/issues/1690 and From patchwork Thu Jun 20 03:44:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 65502 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 4921C27BBEA; Thu, 20 Jun 2024 04:46:32 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5A43127BBE2 for ; Thu, 20 Jun 2024 04:46:31 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK8kL-0006tO-OX; Wed, 19 Jun 2024 23:46:01 -0400 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 ) id 1sK8kK-0006tC-QL for guix-patches@gnu.org; Wed, 19 Jun 2024 23:46:00 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK8kK-0007Sn-IO; Wed, 19 Jun 2024 23:46:00 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sK8kO-0006aH-2c; Wed, 19 Jun 2024 23:46:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71663] [PATCH v2 3/5] services: backup: Add extra-packages field to restic-backup-job Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Thu, 20 Jun 2024 03:46:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71663 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71663@debbugs.gnu.org, 71639@debbugs.gnu.org Cc: Richard Sent , Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-To: guix-patches@gnu.org, 71639@debbugs.gnu.org X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by submit@debbugs.gnu.org id=B.171885514125198 (code B ref -1); Thu, 20 Jun 2024 03:46:03 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jun 2024 03:45:41 +0000 Received: from localhost ([127.0.0.1]:41536 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK8k0-0006YK-Fc for submit@debbugs.gnu.org; Wed, 19 Jun 2024 23:45:40 -0400 Received: from lists.gnu.org ([209.51.188.17]:39452) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK8jy-0006Y5-S3 for submit@debbugs.gnu.org; Wed, 19 Jun 2024 23:45:39 -0400 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 ) id 1sK8ju-0006l1-W6 for guix-patches@gnu.org; Wed, 19 Jun 2024 23:45:35 -0400 Received: from mail-108-mta69.mxroute.com ([136.175.108.69]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK8jl-0007F0-RZ for guix-patches@gnu.org; Wed, 19 Jun 2024 23:45:27 -0400 Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta69.mxroute.com (ZoneMTA) with ESMTPSA id 19033bfb1bd00017a3.002 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 20 Jun 2024 03:45:19 +0000 X-Zone-Loop: c18af7abc3f24ac8dbfb0a74d32d2eaa381dc06cfe84 X-Originating-IP: [136.175.111.3] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=D/jSR4oJbdjWYkLbQ9/74+ANzsyVjGZypdjZdGeHSoQ=; b=lW1HUPBSX4Z0GxvZHPdeP9uvje xi2BogCkv7F9YMSRnmBkV+IUgdrxlquH30pIFRROK/v9yohA+pRTjluW7MM9B0vaP8Q09YfqGT77X 6CVMDtWITy8xUKhc/J5criMz25pQRfYFKHvMWYp1XCCNY+4kMW/mv6FgsgKtD3TTKZ6QMr9QA4Yhr iTc/F9X46+GDgd/MWw95DCsof9L/+rb58Ec93Die8OZSYpC8iL2wCX/qvcaDO/DBPnaSILQnmDO3W xCiJ+2Ca1uVKT++5UkxvgGI56OhGPAXJ6y4qoP3P6lVcVJbBP5iJRbxo4kMqo6c9/ffOx2JivDq0b vbwaULvg==; From: Richard Sent Date: Wed, 19 Jun 2024 23:44:14 -0400 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Authenticated-Id: richard@freakingpenguin.com Received-SPF: pass client-ip=136.175.108.69; envelope-from=richard@freakingpenguin.com; helo=mail-108-mta69.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/backup.scm (restic-backup-job): Create extra-packages. (restic-guix-wrapper-package): Add the extra-packages field of every job as inputs. * doc/guix.texi (Miscellaneous Services): Document it. Change-Id: I4f0b070bc6dc895553ba69256d14e45898291c02 --- doc/guix.texi | 4 ++++ gnu/services/backup.scm | 33 ++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index f22d679023..32ce0c86b9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -41367,6 +41367,10 @@ Miscellaneous Services @item @code{verbose?} (default: @code{#f}) (type: boolean) Whether to enable verbose output for the current backup job. +@item @code{extra-packages} (default: @code{'()} (type: list-of-packages) +The list of extra packages needed for restic to run the current backup +job. + @item @code{extra-flags} (default: @code{'()}) (type: list-of-lowerables) A list of values that are lowered to strings. These will be passed as command-line arguments to the current job @command{restic backup} diff --git a/gnu/services/backup.scm b/gnu/services/backup.scm index fd904bc9a9..bfbacfe590 100644 --- a/gnu/services/backup.scm +++ b/gnu/services/backup.scm @@ -41,6 +41,7 @@ (define-module (gnu services backup) restic-backup-job-files restic-backup-job-init? restic-backup-job-verbose? + restic-backup-job-extra-packages restic-backup-job-extra-flags restic-backup-configuration @@ -102,6 +103,9 @@ (define-configuration/no-serialization restic-backup-job (list-of-lowerables '()) "The list of files or directories to be backed up. It must be a list of values that can be lowered to strings.") + (extra-packages + (list-of-packages '()) + "The list of extra packages needed for restic to run this backup job.") (verbose? (boolean #f) "Whether to enable verbose output for the current backup job.") @@ -237,22 +241,25 @@ (define (restic-backup-job->mcron-job config) #:user #$user))) (define (restic-guix-wrapper-package jobs) - (package - (name "restic-backup-service-wrapper") - (version "0.0.0") - (source (restic-guix jobs)) - (build-system copy-build-system) - (arguments - (list #:install-plan #~'(("./" "/bin")))) - (home-page "https://restic.net") - (synopsis - "Easily interact from the CLI with Guix configured backups") - (description - "This package provides a simple wrapper around @code{restic}, handled + (let ((extra-packages (append-map restic-backup-job-extra-packages + jobs))) + (package + (name "restic-backup-service-wrapper") + (version "0.0.0") + (source (restic-guix restic-package jobs)) + (build-system copy-build-system) + (arguments + (list #:install-plan #~'(("./" "/bin")))) + (home-page "https://restic.net") + (synopsis + "Easily interact from the CLI with Guix configured backups") + (description + "This package provides a simple wrapper around @code{restic}, handled by the @code{restic-backup-service-type}. It allows for easily interacting with Guix configured backup jobs, for example for manually triggering a backup without waiting for the scheduled job to run.") - (license license:gpl3+))) + (inputs extra-packages) + (license license:gpl3+)))) (define restic-backup-service-profile (lambda (config) From patchwork Thu Jun 20 03:44:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 65505 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C120F27BBE9; Thu, 20 Jun 2024 04:46:44 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AC5C127BBED for ; Thu, 20 Jun 2024 04:46:39 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK8kS-0006xu-65; Wed, 19 Jun 2024 23:46:08 -0400 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 ) id 1sK8kP-0006vO-HU for guix-patches@gnu.org; Wed, 19 Jun 2024 23:46:05 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK8kP-0007Tr-9J; Wed, 19 Jun 2024 23:46:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sK8kR-0006bZ-F8; Wed, 19 Jun 2024 23:46:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71639] [PATCH v2 4/5] services: backup: Move restic package to restic-configuration Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Thu, 20 Jun 2024 03:46:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71639 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71639@debbugs.gnu.org Cc: Richard Sent , Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-To: guix-patches@gnu.org, 71639@debbugs.gnu.org X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by 71639-submit@debbugs.gnu.org id=B71639.171885513125144 (code B ref 71639); Thu, 20 Jun 2024 03:46:07 +0000 Received: (at 71639) by debbugs.gnu.org; 20 Jun 2024 03:45:31 +0000 Received: from localhost ([127.0.0.1]:41525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK8jq-0006XN-P7 for submit@debbugs.gnu.org; Wed, 19 Jun 2024 23:45:31 -0400 Received: from mail-108-mta193.mxroute.com ([136.175.108.193]:43377) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK8jo-0006X7-ME for 71639@debbugs.gnu.org; Wed, 19 Jun 2024 23:45:29 -0400 Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta193.mxroute.com (ZoneMTA) with ESMTPSA id 19033bfbb8000017a3.001 for <71639@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 20 Jun 2024 03:45:21 +0000 X-Zone-Loop: dc8bafc96bda104e40d73c2714f8253afbe708a2f9a5 X-Originating-IP: [136.175.111.3] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Vlt6rUXjCF1movO1Sh+fPT/u7XuM91FUt1+2ianbH9o=; b=QKo4caAd2qnZdEsa/ahHUEpPlD ViOhlUKrTkLNK62vYm8hHvaNswp6rii+CCmLNqcPxlYZPZ/KtKmgHPvx11Pv+8jygmonNf6pUMibv 2CLgQH04SDG9S+joknahdk8IzZPt5B4j5ZxkmCEJK5WfqZnuiEMvsheQnzAL/ITi5KL4tbSLmo2Fm qFChcnAOAVpLIhkGtXSapv2TB7x2IceF60xl3TVQWdObXv75caBaW2l/vkRET/CgwHeB70KZ+/Y8k JG4P6Ru0dBfAEhyVhNd4gvfIN9OyqAzxuLgwrgMdhOAvcq1kgqKb7WXj+jo7frQnI1jrnfHiZV3mb BgIEasug==; From: Richard Sent Date: Wed, 19 Jun 2024 23:44:15 -0400 Message-ID: <56345eb5926246798f52424883caa3fd0e88cee8.1718854920.git.richard@freakingpenguin.com> In-Reply-To: References: MIME-Version: 1.0 X-Authenticated-Id: richard@freakingpenguin.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/backup.scm (restic-backup-configuration): Add restic field. (restic-backup-job-program): Add restic package to function signature. (restic-guix): Ditto. (restic-guix-wrapper-package): Ditto. Add restic package as package input. (restic-backup-service-profile): Remove excess lamba. * doc/guix.texi (Miscellaneous Services): Document it. Change-Id: I1e5f63c21cd072354225afe0ee270dca8d9d840b --- doc/guix.texi | 6 +++--- gnu/services/backup.scm | 38 ++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 32ce0c86b9..e4379c5e1c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -41311,6 +41311,9 @@ Miscellaneous Services Available @code{restic-backup-configuration} fields are: @table @asis +@item @code{restic} (default: @code{restic}) (type: package) +The restic package to use for all jobs. + @item @code{jobs} (default: @code{'()}) (type: list-of-restic-backup-jobs) The list of backup jobs for the current system. @@ -41327,9 +41330,6 @@ Miscellaneous Services Available @code{restic-backup-job} fields are: @table @asis -@item @code{restic} (default: @code{restic}) (type: package) -The restic package to be used for the current job. - @item @code{user} (default: @code{"root"}) (type: string) The user used for running the current job. diff --git a/gnu/services/backup.scm b/gnu/services/backup.scm index bfbacfe590..5e2add088e 100644 --- a/gnu/services/backup.scm +++ b/gnu/services/backup.scm @@ -29,10 +29,10 @@ (define-module (gnu services backup) #:use-module (guix modules) #:use-module (guix packages) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:export (restic-backup-job restic-backup-job? restic-backup-job-fields - restic-backup-job-restic restic-backup-job-user restic-backup-job-name restic-backup-job-repository @@ -46,6 +46,7 @@ (define-module (gnu services backup) restic-backup-configuration restic-backup-configuration? + restic-backup-configuration-restic restic-backup-configuration-fields restic-backup-configuration-jobs @@ -71,9 +72,6 @@ (define-maybe/no-serialization string) (define-maybe/no-serialization file-like) (define-configuration/no-serialization restic-backup-job - (restic - (package restic) - "The restic package to be used for the current job.") (user (string "root") "The user used for running the current job.") @@ -129,11 +127,14 @@ (define list-of-restic-backup-jobs? (list-of restic-backup-job?)) (define-configuration/no-serialization restic-backup-configuration + (restic + (package restic) + "The restic package to be used.") (jobs (list-of-restic-backup-jobs '()) "The list of backup jobs for the current system.")) -(define (restic-backup-job-program config) +(define (restic-backup-job-program restic-package config) (define (maybe-value-or-false maybe) (if (maybe-value-set? maybe) maybe @@ -142,7 +143,7 @@ (define (restic-backup-job-program config) (verify-restic-backup-job-configuration config) (let ((restic - (file-append (restic-backup-job-restic config) "/bin/restic")) + (file-append restic-package "/bin/restic")) (repository (restic-backup-job-repository config)) (password-file @@ -189,7 +190,7 @@ (define (restic-backup-job-program config) #$@extra-flags "backup" #$@files))))) -(define (restic-guix jobs) +(define (restic-guix restic-package jobs) (program-file "restic-guix" #~(begin @@ -197,7 +198,7 @@ (define (restic-guix jobs) (srfi srfi-1)) (define names '#$(map restic-backup-job-name jobs)) - (define programs '#$(map restic-backup-job-program jobs)) + (define programs '#$(map (cut restic-backup-job-program restic-package <>) jobs)) (define (get-program name) (define idx @@ -240,13 +241,13 @@ (define (restic-backup-job->mcron-job config) #$(string-append "restic-guix backup " name) #:user #$user))) -(define (restic-guix-wrapper-package jobs) +(define (restic-guix-wrapper-package restic jobs) (let ((extra-packages (append-map restic-backup-job-extra-packages jobs))) (package (name "restic-backup-service-wrapper") (version "0.0.0") - (source (restic-guix restic-package jobs)) + (source (restic-guix restic jobs)) (build-system copy-build-system) (arguments (list #:install-plan #~'(("./" "/bin")))) @@ -258,16 +259,17 @@ (define (restic-guix-wrapper-package jobs) by the @code{restic-backup-service-type}. It allows for easily interacting with Guix configured backup jobs, for example for manually triggering a backup without waiting for the scheduled job to run.") - (inputs extra-packages) + (inputs (cons restic extra-packages)) (license license:gpl3+)))) -(define restic-backup-service-profile - (lambda (config) - (define jobs (restic-backup-configuration-jobs config)) - (if (> (length jobs) 0) - (list - (restic-guix-wrapper-package jobs)) - '()))) +(define (restic-backup-service-profile config) + (let ((jobs (restic-backup-configuration-jobs config)) + (restic (restic-backup-configuration-restic config))) + ;; Even if we provide a wrapper we need to add restic to the profile so + ;; the service works in containers and VMs which only see a subset of + ;; /gnu/store. https://issues.guix.gnu.org/70553. Ergo pass restic to + ;; the wrapper package so it is added as an input. + (list (restic-guix-wrapper-package restic jobs)))) (define restic-backup-service-type (service-type (name 'restic-backup) From patchwork Thu Jun 20 03:44:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 65504 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 28B0D27BBE2; Thu, 20 Jun 2024 04:46:44 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5C76427BBEE for ; Thu, 20 Jun 2024 04:46:41 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK8kN-0006uH-Bg; Wed, 19 Jun 2024 23:46:03 -0400 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 ) id 1sK8kM-0006tm-GD for guix-patches@gnu.org; Wed, 19 Jun 2024 23:46:02 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK8kM-0007Sw-5m for guix-patches@gnu.org; Wed, 19 Jun 2024 23:46:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sK8kP-0006ap-OL for guix-patches@gnu.org; Wed, 19 Jun 2024 23:46:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71665] [PATCH v2 5/5] tests: Add restic system test. Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jun 2024 03:46:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71665 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71665@debbugs.gnu.org, 71639@debbugs.gnu.org Cc: Richard Sent X-Debbugs-Original-To: guix-patches@gnu.org, 71639@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.171885514725231 (code B ref -1); Thu, 20 Jun 2024 03:46:05 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jun 2024 03:45:47 +0000 Received: from localhost ([127.0.0.1]:41542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK8k6-0006Yr-QN for submit@debbugs.gnu.org; Wed, 19 Jun 2024 23:45:47 -0400 Received: from lists.gnu.org ([209.51.188.17]:39478) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sK8k0-0006YL-Nc for submit@debbugs.gnu.org; Wed, 19 Jun 2024 23:45:41 -0400 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 ) id 1sK8jw-0006lp-Rc for guix-patches@gnu.org; Wed, 19 Jun 2024 23:45:36 -0400 Received: from mail-108-mta146.mxroute.com ([136.175.108.146]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK8ju-0007I8-Pq for guix-patches@gnu.org; Wed, 19 Jun 2024 23:45:36 -0400 Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta146.mxroute.com (ZoneMTA) with ESMTPSA id 19033bfc8c300017a3.002 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 20 Jun 2024 03:45:25 +0000 X-Zone-Loop: 3c6e924dc0902687f6a669b936b4546a22748b27af01 X-Originating-IP: [136.175.111.3] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ID4dv26EDja7geOt5SQBFDdNXc/hjEVNkcddZN2hvx0=; b=F+HHUaRzWlrilLBq2mvVYqJyez Aa1mZO6dxkkO+9/5bWjiHa0nWWKgo79NqdOW19SKrarDA2Qzb8j+1+YptHFfBnDJgDpjDByX5eveD 6/S2k3w0Q30tnL3rVPe0ADWv6fewPyJuwnMQo1Za6pKbZ/XpEz3iKx1z9yj5cbm37uJhUtP5SvQ93 qk2HKGUMAAax3gmcRqyVe/p5W7WH1MlmuOjY7X26nkOLXu9fOFBFkumPAGfum1vyVXzmw9/PK54hk 8DTuRs+pOqKJRSGcTEOFpOWD08Jq//gwViD/MYtvXkhXS2N9cJL1U/24d+kXTfDm2FZB1vyfJqPK2 64dAlfiw==; From: Richard Sent Date: Wed, 19 Jun 2024 23:44:16 -0400 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Authenticated-Id: richard@freakingpenguin.com Received-SPF: pass client-ip=136.175.108.146; envelope-from=richard@freakingpenguin.com; helo=mail-108-mta146.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/tests/restic.scm: Create. Change-Id: Iad5472414c140b133d9b402855bb2f01e96bb0cc --- gnu/tests/restic.scm | 119 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 gnu/tests/restic.scm diff --git a/gnu/tests/restic.scm b/gnu/tests/restic.scm new file mode 100644 index 0000000000..8d29ff441b --- /dev/null +++ b/gnu/tests/restic.scm @@ -0,0 +1,119 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2024 Richard Sent . +;;; +;;; 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 . + +(define-module (gnu tests restic) + #:use-module (gnu bootloader) + #:use-module (gnu bootloader grub) + #:use-module (gnu packages) + #:use-module (gnu packages sync) ;rclone + #:use-module (gnu services) + #:use-module (gnu services backup) ;restic + #:use-module (gnu system) + #:use-module (gnu system vm) + #:use-module (gnu tests) + #:use-module (guix gexp) + #:use-module (guix modules) + #:use-module (srfi srfi-1) + #:export (%test-restic)) + +(define password "password") + +(define password-file + (plain-file "password-file" password)) + +(define password-command + (program-file "password-command" #~(display #$password))) + +(define (run-restic-test) + "Run tests in %restic-os." + + (define os + (marionette-operating-system + (simple-operating-system (extra-special-file "/root/.restic-test" + (plain-file "restic-test" + "Hello world!")) + ;; restic-backup-service only takes a string to avoid putting + ;; plaintext entries in the store. Ergo, symlink it. + (extra-special-file "/root/password-file" + password-file) + (service restic-backup-service-type + (restic-backup-configuration + (jobs + (list (restic-backup-job + (name "password-file-backup") + (repository "/root/restic-password-file-repo") + (schedule #~'(next-second '(0 15 30 45))) + (password-file "/root/password-file") + (files '("/root/.restic-test")) + (init? #t)) + (restic-backup-job + (name "password-command-backup") + (repository "/root/restic-password-command-repo") + (schedule #~'(next-second '(0 15 30 45))) + (password-command password-command) + (files '("/root/.restic-test")) + (init? #t))))))) + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define vm (virtual-machine + (operating-system os) + (memory-size 512))) + + (define test + (with-imported-modules (source-module-closure + '((gnu build marionette))) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-26) + (srfi srfi-64)) + + (let ((marionette (make-marionette (list #$vm)))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "restic") + + (test-assert "backup-file-created" + (wait-for-file "/root/.restic-test" marionette)) + + (test-assert "mcron running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'mcron)) + marionette)) + + (test-assert "password-file backup completed" + (wait-for-file "/root/restic-password-file-repo/config" marionette + ;; Restic takes a second to run, give it a bit + ;; more time. + #:timeout 20)) + + (test-assert "password-comand backup completed" + (wait-for-file "/root/restic-password-file-repo/config" marionette + #:timeout 20)) + + (test-end))))) + + (gexp->derivation "restic-test" test)) + +(define %test-restic + (system-test + (name "restic") + (description "Basic tests for the restic service.") + (value (run-restic-test))))