From patchwork Sun Mar 14 12:04:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: raid5atemyhomework X-Patchwork-Id: 27691 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 9A39B27BC54; Sun, 14 Mar 2021 12:05:16 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id DF32827BC52 for ; Sun, 14 Mar 2021 12:05:15 +0000 (GMT) Received: from localhost ([::1]:56762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLPUg-0003Q1-TJ for patchwork@mira.cbaines.net; Sun, 14 Mar 2021 08:05:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLPUU-0003P2-7w for guix-patches@gnu.org; Sun, 14 Mar 2021 08:05:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLPUT-0002nl-W1 for guix-patches@gnu.org; Sun, 14 Mar 2021 08:05:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lLPUT-0002h7-RA for guix-patches@gnu.org; Sun, 14 Mar 2021 08:05:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47134] [PATCH v2] gnu: Add zfs-auto-snapshot. References: <8khDgDFm8YAH3rsudpda_ASV2o4CdQLmejmEXU3QkRkUFrMfewbzBrqrC4OO2mvpuQUckFSwYmSGadSjNy87Z7NKas5fupZILvGtvPJSa3Y=@protonmail.com> In-Reply-To: <8khDgDFm8YAH3rsudpda_ASV2o4CdQLmejmEXU3QkRkUFrMfewbzBrqrC4OO2mvpuQUckFSwYmSGadSjNy87Z7NKas5fupZILvGtvPJSa3Y=@protonmail.com> Resent-From: raid5atemyhomework Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 14 Mar 2021 12:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47134 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "47134@debbugs.gnu.org" <47134@debbugs.gnu.org> Received: via spool by 47134-submit@debbugs.gnu.org id=B47134.161572346610312 (code B ref 47134); Sun, 14 Mar 2021 12:05:01 +0000 Received: (at 47134) by debbugs.gnu.org; 14 Mar 2021 12:04:26 +0000 Received: from localhost ([127.0.0.1]:33033 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLPTt-0002gF-N5 for submit@debbugs.gnu.org; Sun, 14 Mar 2021 08:04:26 -0400 Received: from mail-40137.protonmail.ch ([185.70.40.137]:43630) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLPTr-0002g0-4n for 47134@debbugs.gnu.org; Sun, 14 Mar 2021 08:04:24 -0400 Date: Sun, 14 Mar 2021 12:04:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1615723456; bh=dYKEpjEbjlGCrlXcux20oCUS/t98LuWSMbClpXPXI1o=; h=Date:To:From:Reply-To:Subject:From; b=dA7zYa5nBkeBcB8U0fAuruFZhQggxzHsfoLViFU4B75XfonoMmW8wutJFlNsl0M3F NAg4ykNDvzpc8j0jtH99WCemkNz1gqmGOp2ddDB5NpwnshlZxrWflx8QOz1dXTzK+k hyL+QeZ1MpPIPCWCm9zxoHk2GolXKlYYiznKhzDQ= Message-ID: MIME-Version: 1.0 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" Reply-to: raid5atemyhomework X-ACL-Warn: , raid5atemyhomework via Guix-patches X-Patchwork-Original-From: raid5atemyhomework via Guix-patches via From: raid5atemyhomework X-getmail-retrieved-from-mailbox: Patches Have it refer to specific zfs package. Users that inherit from the zfs package in order to compile for a specific kernel version should also inherit from this package and pass in their zfs. Testing done: * `guix build -f zfs-auto-snapshot.scm` on a scheme file containing only this package. * Ran the hourly, daily, weekly, and monthly scripts "by hand". Also confirmed `com.sun:auto-snapshot` and `com.sun:auto-snapshot:*` settings work. * Currently have it running in a homelab server with mcron triggers on the hourly, daily, weekly, and monthly scripts, at least one hourly trigger has passed and snapshots were indeed created without any errors in `/var/log/messages`. * Checked the installed scripts and verified that the `zfs` and `zpool` commands refer to specific in-store binaries. Please merge! Thanks raid5atemyhomework From 7425298029dd1c9b4f2b3bba675ddbe7eb730744 Mon Sep 17 00:00:00 2001 From: raid5atemyhomework Date: Sun, 14 Mar 2021 16:40:47 +0800 Subject: [PATCH] gnu: Add zfs-auto-snapshot. * gnu/packages/file-systems.scm (zfs-auto-snapshot): New variable. --- gnu/packages/file-systems.scm | 75 +++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) -- 2.30.2 diff --git a/gnu/packages/file-systems.scm b/gnu/packages/file-systems.scm index e7d78e41fb..4d01b3da46 100644 --- a/gnu/packages/file-systems.scm +++ b/gnu/packages/file-systems.scm @@ -975,6 +975,81 @@ originally developed for Solaris and is now maintained by the OpenZFS community.") (license license:cddl1.0))) +(define-public zfs-auto-snapshot + (package + (name "zfs-auto-snapshot") + (version "1.2.4") + (source + (origin + (method url-fetch) + (uri (string-append + "https://github.com/zfsonlinux/zfs-auto-snapshot/archive/upstream/" + version ".tar.gz")) + (sha256 + (base32 "16ry1w43i44xc67gr73x6fa48ninfhqxr498ad4m3kya93vp2zrh")))) + (build-system gnu-build-system) + (inputs + ;; Note: if you are inheriting from the above zfs package in order + ;; to provide a specific stable kernel version, you should also + ;; inherit this package and replace the sole input below. + `(("zfs" ,zfs))) + (arguments + `(#:tests? #f ; No tests + #:phases + (modify-phases %standard-phases + (delete 'configure) + (delete 'build) + ;; Guix System may not have a traditional cron system, but + ;; the cron scripts installed by this package are convenient + ;; to use as targets for an mcron job specification, so make + ;; sure they can be run in-store. + (add-before 'install 'fix-scripts + (lambda* (#:key outputs inputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (zfs-auto-snapshot (string-append + out + "/sbin/zfs-auto-snapshot")) + (zfs-package (assoc-ref inputs "zfs")) + (zpool (string-append + zfs-package + "/sbin/zpool")) + (zfs (string-append + zfs-package + "/sbin/zfs"))) + (substitute* '("etc/zfs-auto-snapshot.cron.daily" + "etc/zfs-auto-snapshot.cron.frequent" + "etc/zfs-auto-snapshot.cron.hourly" + "etc/zfs-auto-snapshot.cron.monthly" + "etc/zfs-auto-snapshot.cron.weekly") + (("zfs-auto-snapshot") + zfs-auto-snapshot)) + (substitute* "src/zfs-auto-snapshot.sh" + (("LC_ALL=C zfs list") + (string-append "LC_ALL=C " zfs " list")) + (("LC_ALL=C zpool status") + (string-append "LC_ALL=C " zpool " status")) + (("zfs snapshot") + (string-append zfs " snapshot")) + (("zfs destroy") + (string-append zfs " destroy")))))) + ;; Provide DESTDIR and PREFIX on make command. + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (invoke "make" "install" + "PREFIX=" + (string-append "DESTDIR=" out))) + #t))))) + (home-page "https://github.com/zfsonlinux/zfs-auto-snapshot") + (synopsis "Automatically create, rotate, and destroy periodic ZFS snapshots") + (description + "An alternative implementation of the zfs-auto-snapshot service for Linux +that is compatible with zfs-linux and zfs-fuse. + +On Guix System, you will need to invoke the included shell scripts as @code{job} +definitions in your @code{operating-system} declaration.") + (license license:gpl2+))) + (define-public mergerfs (package (name "mergerfs")