diff options
author | Naïm Favier <n@monade.li> | 2022-12-17 17:00:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-17 17:00:02 +0100 |
commit | 723eb8d9b8f56f6c16c58506c177d9be3047538f (patch) | |
tree | 7797bbca35fe137243c8669c16aa767b579a4809 /nixos | |
parent | a23134f464d23d69cd30938349b64d29fbe670bf (diff) | |
parent | cb4547a433dfb0581c5ab389eedb49618fa902e7 (diff) |
Merge pull request #205479 from IzumiRaine/borgbackup-patterns
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/backup/borgbackup.nix | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/nixos/modules/services/backup/borgbackup.nix b/nixos/modules/services/backup/borgbackup.nix index 0ae3d4180ae75..ae8e1dd8463bf 100644 --- a/nixos/modules/services/backup/borgbackup.nix +++ b/nixos/modules/services/backup/borgbackup.nix @@ -11,7 +11,11 @@ let mkExcludeFile = cfg: # Write each exclude pattern to a new line - pkgs.writeText "excludefile" (concatStringsSep "\n" cfg.exclude); + pkgs.writeText "excludefile" (concatMapStrings (s: s + "\n") cfg.exclude); + + mkPatternsFile = cfg: + # Write each pattern to a new line + pkgs.writeText "patternsfile" (concatMapStrings (s: s + "\n") cfg.patterns); mkKeepArgs = cfg: # If cfg.prune.keep e.g. has a yearly attribute, @@ -47,6 +51,7 @@ let borg create $extraArgs \ --compression ${cfg.compression} \ --exclude-from ${mkExcludeFile cfg} \ + --patterns-from ${mkPatternsFile cfg} \ $extraCreateArgs \ "::$archiveName$archiveSuffix" \ ${if cfg.paths == null then "-" else escapeShellArgs cfg.paths} @@ -441,6 +446,21 @@ in { ]; }; + patterns = mkOption { + type = with types; listOf str; + description = lib.mdDoc '' + Include/exclude paths matching the given patterns. The first + matching patterns is used, so if an include pattern (prefix `+`) + matches before an exclude pattern (prefix `-`), the file is + backed up. See [{command}`borg help patterns`](https://borgbackup.readthedocs.io/en/stable/usage/help.html#borg-patterns) for pattern syntax. + ''; + default = [ ]; + example = [ + "+ /home/susan" + "- /home/*" + ]; + }; + readWritePaths = mkOption { type = with types; listOf path; description = lib.mdDoc '' |