diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-11-01 22:43:25 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-11-01 22:43:25 +0100 |
commit | 7448d3431fcfc05f9b7991e337b02083300a99db (patch) | |
tree | 0664ebc0f666ef404881ac7287198ff44c0ba9e0 /modules/zfssnap | |
parent | 234eab10a84e7ffb8bbc32f5e2f94495d3c9aedd (diff) | |
download | nixos-7448d3431fcfc05f9b7991e337b02083300a99db.tar nixos-7448d3431fcfc05f9b7991e337b02083300a99db.tar.gz nixos-7448d3431fcfc05f9b7991e337b02083300a99db.tar.bz2 nixos-7448d3431fcfc05f9b7991e337b02083300a99db.tar.xz nixos-7448d3431fcfc05f9b7991e337b02083300a99db.zip |
...
Diffstat (limited to 'modules/zfssnap')
-rw-r--r-- | modules/zfssnap/default.nix | 18 | ||||
-rw-r--r-- | modules/zfssnap/zfssnap/zfssnap/__main__.py | 3 |
2 files changed, 19 insertions, 2 deletions
diff --git a/modules/zfssnap/default.nix b/modules/zfssnap/default.nix index f46cd510..f6f32852 100644 --- a/modules/zfssnap/default.nix +++ b/modules/zfssnap/default.nix | |||
@@ -48,6 +48,20 @@ in { | |||
48 | type = types.str; | 48 | type = types.str; |
49 | default = "*-*-* *:00/5:00"; | 49 | default = "*-*-* *:00/5:00"; |
50 | }; | 50 | }; |
51 | |||
52 | verbosity = mkOption { | ||
53 | type = types.int; | ||
54 | default = 2; | ||
55 | }; | ||
56 | |||
57 | extraPruneArgs = mkOption { | ||
58 | type = with types; listOf str; | ||
59 | default = []; | ||
60 | }; | ||
61 | extraAutosnapArgs = mkOption { | ||
62 | type = with types; listOf str; | ||
63 | default = []; | ||
64 | }; | ||
51 | }; | 65 | }; |
52 | }; | 66 | }; |
53 | 67 | ||
@@ -59,7 +73,7 @@ in { | |||
59 | before = [ "zfssnap-prune.service" ]; | 73 | before = [ "zfssnap-prune.service" ]; |
60 | serviceConfig = { | 74 | serviceConfig = { |
61 | Type = "oneshot"; | 75 | Type = "oneshot"; |
62 | ExecStart = "${zfssnap}/bin/zfssnap -vv"; | 76 | ExecStart = "${zfssnap}/bin/zfssnap --verbosity=${toString cfg.verbosity} autosnap ${escapeShellArgs cfg.extraAutosnapArgs}"; |
63 | 77 | ||
64 | LogRateLimitIntervalSec = 0; | 78 | LogRateLimitIntervalSec = 0; |
65 | }; | 79 | }; |
@@ -72,7 +86,7 @@ in { | |||
72 | ExecStart = let | 86 | ExecStart = let |
73 | mkSectionName = name: strings.escape [ "[" "]" ] (strings.toUpper name); | 87 | mkSectionName = name: strings.escape [ "[" "]" ] (strings.toUpper name); |
74 | zfssnapConfig = generators.toINI { inherit mkSectionName; } cfg.config; | 88 | zfssnapConfig = generators.toINI { inherit mkSectionName; } cfg.config; |
75 | in "${zfssnap}/bin/zfssnap -vv prune --config=${pkgs.writeText "zfssnap.ini" zfssnapConfig}"; | 89 | in "${zfssnap}/bin/zfssnap --verbosity=${toString cfg.verbosity} prune --config=${pkgs.writeText "zfssnap.ini" zfssnapConfig} ${escapeShellArgs cfg.extraPruneArgs}"; |
76 | 90 | ||
77 | LogRateLimitIntervalSec = 0; | 91 | LogRateLimitIntervalSec = 0; |
78 | }; | 92 | }; |
diff --git a/modules/zfssnap/zfssnap/zfssnap/__main__.py b/modules/zfssnap/zfssnap/zfssnap/__main__.py index 9d07401b..59478c71 100644 --- a/modules/zfssnap/zfssnap/zfssnap/__main__.py +++ b/modules/zfssnap/zfssnap/zfssnap/__main__.py | |||
@@ -375,10 +375,13 @@ def main(): | |||
375 | sys.excepthook = log_exceptions | 375 | sys.excepthook = log_exceptions |
376 | 376 | ||
377 | parser = argparse.ArgumentParser(prog='zfssnap') | 377 | parser = argparse.ArgumentParser(prog='zfssnap') |
378 | parser.add_argument('--verbosity', dest='log_level', action='append') | ||
378 | parser.add_argument('--verbose', '-v', dest='log_level', action='append_const', const=-1) | 379 | parser.add_argument('--verbose', '-v', dest='log_level', action='append_const', const=-1) |
379 | parser.add_argument('--quiet', '-q', dest='log_level', action='append_const', const=1) | 380 | parser.add_argument('--quiet', '-q', dest='log_level', action='append_const', const=1) |
380 | subparsers = parser.add_subparsers() | 381 | subparsers = parser.add_subparsers() |
381 | parser.set_defaults(cmd=autosnap) | 382 | parser.set_defaults(cmd=autosnap) |
383 | autosnap_parser = subparsers.add_parser('autosnap') | ||
384 | autosnap_parser.set_defaults(cmd=autosnap) | ||
382 | rename_parser = subparsers.add_parser('rename') | 385 | rename_parser = subparsers.add_parser('rename') |
383 | rename_parser.add_argument('snapshots', nargs='+') | 386 | rename_parser.add_argument('snapshots', nargs='+') |
384 | rename_parser.add_argument('--destroy', action='store_true', default=False) | 387 | rename_parser.add_argument('--destroy', action='store_true', default=False) |