From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id gELsHnBB1mZaqwAA62LTzQ:P1 (envelope-from ) for ; Mon, 02 Sep 2024 22:51:28 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id gELsHnBB1mZaqwAA62LTzQ (envelope-from ) for ; Tue, 03 Sep 2024 00:51:28 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=PqrpDSf4; dkim=fail ("headers rsa verify failed") header.d=fabionatali.com header.s=gm1 header.b=Vt2lesrI; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1725317488; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=zVwD/Hx7vdZFJhIk5GDsRn673VPz4/5kMwYrr0fM0fE=; b=NlNQ3IE21jwH2sgUrUbHz057M7WIv0uUUHfb50nGkq8CZ7NEJ6w9h9C7+v5oJAE8cpW0k+ Y2NU0D3/lVrb1ST5Yc7qLW238XZMmrHwhv7O7mS+5sYUZ+N3g0RcLDfPzPrztT5vyv8FAB dJAzP5nAFg2qgSWNZqdTPjrxJNEFWzc+DTwU2wzLFpdg5dbcwAoCP8Nup5JNwTTKIW4vk9 Ax83QupPxlEdEt2X/mceHIgB6/C7do9iAYkhKhp9AF991HRFW/XCxmExaRqNZM64grCgDj oWB180mM3PrLnugONMNdq0dN5QvneRIbo0KTeVbw8WekRWFk5iMsKYfeKGMgfA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=PqrpDSf4; dkim=fail ("headers rsa verify failed") header.d=fabionatali.com header.s=gm1 header.b=Vt2lesrI; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1725317488; a=rsa-sha256; cv=none; b=nI5asnLP/wAXIGIHz8SY3RXIjcnuTlcHtSY4sTkGyNe1yE6g61nhaDhbIt4DNIwM86/YRt +iaPZ2Bu0eJtDA46xWf/NOxbAopRGlwAadGjOCS0qunMtEWjn87r4dMotjUQ8L8XGbvcpd evA+MO0kytf3zuaaZsdHzqdqYqntUhDDb1/g3DYywjCkb+SngtU2stCGb3njq17fmwqDQu wH5vfNQDzakKFMAcMwXPvs2EEpkISa/DMRNET1ltKDtJQsZepj5uqCsEdJrA0UbqlXQ223 x7YurOmG94r7wMztMyjlpfgGNK/YQNajgMLyBi01ay3jvlk8GHc0bByIRGTX3A== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6DE9280E1 for ; Tue, 3 Sep 2024 00:51:27 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slFt0-00061U-QJ; Mon, 02 Sep 2024 18:51:02 -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 1slFsz-00061E-9X for guix-patches@gnu.org; Mon, 02 Sep 2024 18:51:01 -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 1slFsy-0007V4-W7 for guix-patches@gnu.org; Mon, 02 Sep 2024 18:51:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:In-Reply-To:From:To:References:Subject; bh=zVwD/Hx7vdZFJhIk5GDsRn673VPz4/5kMwYrr0fM0fE=; b=PqrpDSf4nSgmdtn0SDLA2wLM4tmrwBbOD1uOq0peJ3wj8VGx25jNreq6YofdhwTjTFd8bSEzjEf/Yh8xvhfAF38WSWGlpE07/mD50dMVO4LCegAt6cEK5UcpHewPZAdRHwOF6NXjzqE0SKPwyPB6RJWgJQ15BB0Ks+0sK7nq7TelKSRcz8+BUNY8XLtMDu5hI2HC1DrG/2DBFRSaBx72kAvo2DN7z8ot0tYY8cbjsCdKuPaUlh6sKRDevaByeerZHFMt110gNhCxZCIP63bKCTju8J0jOxHa9BbmXytzb1XPmFZjTp9mDHApsXO+iXdfP9U6vB4RVKC2MIuS/JOpvA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1slFty-0001Fi-C1 for guix-patches@gnu.org; Mon, 02 Sep 2024 18:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#72803] Add restic commands to the restic-guix package References: Resent-From: Fabio Natali Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 02 Sep 2024 22:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72803 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 72803@debbugs.gnu.org Cc: Giacomo Leidi Received: via spool by 72803-submit@debbugs.gnu.org id=B72803.17253174914735 (code B ref 72803); Mon, 02 Sep 2024 22:52:02 +0000 Received: (at 72803) by debbugs.gnu.org; 2 Sep 2024 22:51:31 +0000 Received: from localhost ([127.0.0.1]:52863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slFtS-0001EJ-JQ for submit@debbugs.gnu.org; Mon, 02 Sep 2024 18:51:31 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:45891) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slFtP-0001Dy-5E for 72803@debbugs.gnu.org; Mon, 02 Sep 2024 18:51:29 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 0276020002; Mon, 2 Sep 2024 22:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fabionatali.com; s=gm1; t=1725317419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=zVwD/Hx7vdZFJhIk5GDsRn673VPz4/5kMwYrr0fM0fE=; b=Vt2lesrIFuR1uRv2RqeKHTpF54DDporhHOKlQ/jF43KpPuio4d+7tIxlBAb3xIeFocn5f4 Up3OG7wboT02ab9P/mevL0tgdTg2ffMk+UmGMO5o3urlrVG6NtRGN/PxXSFpxuoi1BWaxf fn4b5/N9GiZFEcj18ONqmHzJ8gQgXtd497t0wOQGyU/Iw9QI1yx59ZMk0rKHxKPY51L+nt 4T2Bl+HjmSTd++PavUO4kqbTWEq3MxisIfTdixoDUqainB6OqWTTdJXoIkb1uv7ry+oRcs dvpH6ms4ax4eYYsha7cFvNDdDbbmya/g7DDGcE3WsH917gIRvbGyB4Sv9asz9Q== In-Reply-To: <1084765da10bf285803cbb7457997f73f785983d.1724594201.git.goodoldpaul@autistici.org> Date: Mon, 02 Sep 2024 23:50:17 +0100 Message-ID: <8734mhfz6e.fsf@fabionatali.com> MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: me@fabionatali.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: , Reply-to: Fabio Natali X-ACL-Warn: , Fabio Natali via Guix-patches From: Fabio Natali via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -7.08 X-Migadu-Queue-Id: 6DE9280E1 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -7.08 X-TUID: z36x2WONRFwf Hi Giacomo, Thanks for the patch and for the Restic service in the first place. > diff --git a/doc/guix.texi b/doc/guix.texi In the manual, consider the "extra-flags" section where we say: > A list of values that are lowered to strings. These will be passed as > command-line arguments to the current job restic backup invokation. Perhaps this should now read "...the current job restic invokation..." or "...the current restic invokation...", as the action is no longer limited to "backup"? > (program-file > - "restic-backup-job.scm" > + (string-append "restic-" action "-" name "-program.scm") Should 'name' be slug-ified in any way here? E.g. to avoid spaces, capital letters, symbols that might be confusing when part of a file name, etc. > + (define action-table > + (map > + (lambda (action) > + (list action > + (map (lambda (job) > + (list (restic-backup-job-name job) > + (restic-action-program job action))) > + jobs))) > + ;; run is an alias for backup > + (filter (lambda (a) (not (string=? a "run"))) supported-actions))) Could this be (marginally) simpler if we used two nested association lists? That way, 'get-program' might simply use 'assoc-ref' (twice) and 'assoc-table' would be redundant? Everything else looks fine to me. For what it's worth, here's how I've been testing this. Initialise a Restic repository as follows (warning: this overwrites '/some-temporary-folder/password'): --8<---------------cut here---------------start------------->8--- mkdir /some-temporary-folder export RESTIC_PASSWORD=password restic init --repo=/some-temporary-folder/repository echo "${RESTIC_PASSWORD}" > /some-temporary-folder/password --8<---------------cut here---------------end--------------->8--- Save the following system definition as '/some-temporary-folder/config.scm'. --8<---------------cut here---------------start------------->8--- (use-modules (gnu)) (use-package-modules backup) (use-service-modules backup) (operating-system (host-name "host") (bootloader (bootloader-configuration (bootloader grub-bootloader) (targets '("/dev/vda")))) (file-systems (cons (file-system (device "/dev/vda1") (mount-point "/") (type "ext4")) %base-file-systems)) (packages (cons* restic %base-packages)) (services (cons* (service restic-backup-service-type (restic-backup-configuration (jobs (list (restic-backup-job (name "test") (repository "/restic/repository") (password-file "/restic/password") (schedule "* * * * *") (files '("/root"))))))) %base-services))) --8<---------------cut here---------------end--------------->8--- >From a Guix checkout where this patch has been applied, launch a test VM as follows: --8<---------------cut here---------------start------------->8--- $(./pre-inst-env guix system vm \ --no-graphic \ --share=/some-temporary-folder=/restic \ /tmp/config.scm) \ -m 2048 -smp 2 --8<---------------cut here---------------end--------------->8--- Log in as root, then check that the cron schedule is correctly defined with 'herd schedule mcron', backup jobs should be scheduled every minute. Mount the Restic repository to see that snapshots have been actually created every minute since boot. This can be done either on the guest or on the host system. E.g. on the guest: --8<---------------cut here---------------start------------->8--- restic mount \ --password-file=/restic/password \ --repo=/restic/repository \ /mnt --8<---------------cut here---------------end--------------->8--- Unfortunately I don't have commit access to push this, but hopefully someone else will have a second look and push it soon. It'd be nice to have a little test suite for this, but in case this can be part of a future patch. HTH, thanks, Fabio.