Merge pull request #7163 from joachifm/tarsnap-bandwidth-options

tarsnap module: add options for controlling bandwidth

+31 -3
+31 -3
nixos/modules/services/backup/tarsnap.nix
··· 5 let 6 cfg = config.services.tarsnap; 7 8 - optionalNullStr = e: v: if e == null then "" else v; 9 - 10 configFile = cfg: '' 11 cachedir ${config.services.tarsnap.cachedir} 12 keyfile ${config.services.tarsnap.keyfile} 13 ${optionalString cfg.nodump "nodump"} 14 ${optionalString cfg.printStats "print-stats"} 15 ${optionalString cfg.printStats "humanize-numbers"} 16 - ${optionalNullStr cfg.checkpointBytes "checkpoint-bytes "+cfg.checkpointBytes} 17 ${optionalString cfg.aggressiveNetworking "aggressive-networking"} 18 ${concatStringsSep "\n" (map (v: "exclude "+v) cfg.excludes)} 19 ${concatStringsSep "\n" (map (v: "include "+v) cfg.includes)} 20 ${optionalString cfg.lowmem "lowmem"} 21 ${optionalString cfg.verylowmem "verylowmem"} 22 ''; 23 in 24 { ··· 164 Reduce memory consumption by a factor of 2 beyond what 165 <literal>lowmem</literal> does, at the cost of significantly 166 slowing down the archiving process. 167 ''; 168 }; 169 };
··· 5 let 6 cfg = config.services.tarsnap; 7 8 configFile = cfg: '' 9 cachedir ${config.services.tarsnap.cachedir} 10 keyfile ${config.services.tarsnap.keyfile} 11 ${optionalString cfg.nodump "nodump"} 12 ${optionalString cfg.printStats "print-stats"} 13 ${optionalString cfg.printStats "humanize-numbers"} 14 + ${optionalString (cfg.checkpointBytes != null) ("checkpoint-bytes "+cfg.checkpointBytes)} 15 ${optionalString cfg.aggressiveNetworking "aggressive-networking"} 16 ${concatStringsSep "\n" (map (v: "exclude "+v) cfg.excludes)} 17 ${concatStringsSep "\n" (map (v: "include "+v) cfg.includes)} 18 ${optionalString cfg.lowmem "lowmem"} 19 ${optionalString cfg.verylowmem "verylowmem"} 20 + ${optionalString (cfg.maxbw != null) ("maxbw "+toString cfg.maxbw)} 21 + ${optionalString (cfg.maxbwRateUp != null) ("maxbw-rate-up "+toString cfg.maxbwRateUp)} 22 + ${optionalString (cfg.maxbwRateDown != null) ("maxbw-rate-down "+toString cfg.maxbwRateDown)} 23 ''; 24 in 25 { ··· 165 Reduce memory consumption by a factor of 2 beyond what 166 <literal>lowmem</literal> does, at the cost of significantly 167 slowing down the archiving process. 168 + ''; 169 + }; 170 + 171 + maxbw = mkOption { 172 + type = types.nullOr types.int; 173 + default = null; 174 + description = '' 175 + Abort archival if upstream bandwidth usage in bytes 176 + exceeds this threshold. 177 + ''; 178 + }; 179 + 180 + maxbwRateUp = mkOption { 181 + type = types.nullOr types.int; 182 + default = null; 183 + example = literalExample "25 * 1000"; 184 + description = '' 185 + Upload bandwidth rate limit in bytes. 186 + ''; 187 + }; 188 + 189 + maxbwRateDown = mkOption { 190 + type = types.nullOr types.int; 191 + default = null; 192 + example = literalExample "50 * 1000"; 193 + description = '' 194 + Download bandwidth rate limit in bytes. 195 ''; 196 }; 197 };