about summary refs log tree commit diff
path: root/modules/services/backup/default.nix
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-06-09 14:36:35 -0700
committerFranck Cuny <franck@fcuny.net>2022-06-09 14:37:44 -0700
commit68ca85983d34d52abbc041cddc244201a35363fb (patch)
tree12b6079cff3b30b3f5cce2785a767e41e3d578ab /modules/services/backup/default.nix
parentfix(gerrit): don't backup tmp,logs,cache directories (diff)
downloadworld-68ca85983d34d52abbc041cddc244201a35363fb.tar.gz
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 <franck@fcuny.net>
Diffstat (limited to '')
-rw-r--r--modules/services/backup/default.nix10
1 files 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;