GNU bug report logs -
#71661
[PATCH v2 1/5] services: backup: Support bootstrapping an initial restic backup
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 71661 in the body.
You can then email your comments to 71661 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:
bug#71661
; Package
guix-patches
.
(Thu, 20 Jun 2024 03:46:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Richard Sent <richard <at> freakingpenguin.com>
:
New bug report received and forwarded. Copy sent to
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
.
(Thu, 20 Jun 2024 03:46:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* 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 <goodoldpaul <at> autistici.org>
+;;; Copyright © 2024 Richard Sent <richard <at> freakingpenguin.com>
;;;
;;; 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
--
2.45.1
bug closed, send any further explanations to
71661 <at> debbugs.gnu.org and Richard Sent <richard <at> freakingpenguin.com>
Request was from
Richard Sent <richard <at> freakingpenguin.com>
to
control <at> debbugs.gnu.org
.
(Thu, 20 Jun 2024 20:59:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 20 Jul 2024 11:24:10 GMT)
Full text and
rfc822 format available.
This bug report was last modified 335 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.