From 68ca85983d34d52abbc041cddc244201a35363fb Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Thu, 9 Jun 2022 14:36:35 -0700 Subject: fix(restic): actually exclude files from the backup The option `exclude' was defined but unused. Add a function to generate a text file containing all the paths that we want to exclude, and provide that file as an option when we call `restic'. Change-Id: I647db892a8a77c589cec1fc975808c5c9ad0b757 Reviewed-on: https://cl.fcuny.net/c/world/+/362 Tested-by: CI Reviewed-by: Franck Cuny --- modules/services/backup/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/services/backup/default.nix b/modules/services/backup/default.nix index 2db1aa8..e935b64 100644 --- a/modules/services/backup/default.nix +++ b/modules/services/backup/default.nix @@ -1,5 +1,10 @@ { config, pkgs, lib, ... }: -let cfg = config.my.services.backup; +let + cfg = config.my.services.backup; + excludeArg = with builtins; + with pkgs; + "--exclude-file=" + + (writeText "excludes.txt" (concatStringsSep "\n" cfg.exclude)); in { options.my.services.backup = with lib; { enable = mkEnableOption "Enable backups for this host"; @@ -82,7 +87,8 @@ in { services.restic.backups.host = { # Take care of included and excluded files paths = cfg.paths; - extraBackupArgs = [ "--verbose=2" ]; + extraBackupArgs = [ "--verbose=2" ] + ++ lib.optional (builtins.length cfg.exclude != 0) excludeArg; # Take care of creating the repository if it doesn't exist initialize = true; inherit (cfg) passwordFile pruneOpts timerConfig repository user; -- cgit 1.4.1