From 81312eed0f1c96c826eedec5ed429560306ef598 Mon Sep 17 00:00:00 2001 From: Joseph Hanson Date: Sat, 27 Jul 2024 16:27:50 -0500 Subject: [PATCH] Add the ability ignore messages for servers that have no state to backup that are production. --- nixos/hosts/gandalf/default.nix | 2 ++ nixos/hosts/telperion/default.nix | 2 ++ nixos/modules/nixos/services/restic/default.nix | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/nixos/hosts/gandalf/default.nix b/nixos/hosts/gandalf/default.nix index 67e7465..cef5e00 100644 --- a/nixos/hosts/gandalf/default.nix +++ b/nixos/hosts/gandalf/default.nix @@ -84,6 +84,8 @@ in samba.extraConfig = import ./config/samba-config.nix { }; resticBackup.local.enable = false; resticBackup.remote.enable = false; + resticBackup.local.noWarning = true; + resticBackup.remote.noWarning = true; # Borg borgbackup = { enable = true; diff --git a/nixos/hosts/telperion/default.nix b/nixos/hosts/telperion/default.nix index ca5ff3e..56b52d7 100644 --- a/nixos/hosts/telperion/default.nix +++ b/nixos/hosts/telperion/default.nix @@ -68,6 +68,8 @@ system.motd.networkInterfaces = [ "enp2s0" "wlp3s0" ]; system.resticBackup.local.enable = false; system.resticBackup.remote.enable = false; + system.resticBackup.local.noWarning = true; + system.resticBackup.remote.noWarning = true; services = { podman.enable = true; diff --git a/nixos/modules/nixos/services/restic/default.nix b/nixos/modules/nixos/services/restic/default.nix index c1795d3..b2122b2 100644 --- a/nixos/modules/nixos/services/restic/default.nix +++ b/nixos/modules/nixos/services/restic/default.nix @@ -7,6 +7,12 @@ in options.mySystem.system.resticBackup = { local = { enable = mkEnableOption "Local backups" // { default = true; }; + noWarning = mkOption + { + type = types.bool; + description = "Disable warning for local backups"; + default = false; + }; location = mkOption { type = types.str; @@ -16,6 +22,12 @@ in }; remote = { enable = mkEnableOption "Remote backups" // { default = true; }; + noWarning = mkOption + { + type = types.bool; + description = "Disable warning for remote backups"; + default = false; + }; location = mkOption { type = types.str; @@ -34,8 +46,8 @@ in # Warn if backups are disable and machine isnt a dev box warnings = [ - (mkIf (!cfg.local.enable && config.mySystem.purpose != "Development") "WARNING: Local backups are disabled for ${config.system.name}!") - (mkIf (!cfg.remote.enable && config.mySystem.purpose != "Development") "WARNING: Remote backups are disabled for ${config.system.name}!") + (mkIf (!cfg.local.noWarning && !cfg.local.enable && config.mySystem.purpose != "Development") "WARNING: Local backups are disabled for ${config.system.name}!") + (mkIf (!cfg.remote.noWarning && !cfg.remote.enable && config.mySystem.purpose != "Development") "WARNING: Remote backups are disabled for ${config.system.name}!") ]; sops.secrets = mkIf (cfg.local.enable || cfg.remote.enable) {