Browse code

Option to ignore certain snapshot names

Lorenz Hüdepohl authored on 05/12/2017 21:48:01
Showing 1 changed files
... ...
@@ -29,6 +29,10 @@ parser.add_argument('--snapname', metavar='TAGNAME', type=str, action='append',
29 29
                     help='Only consider snapshot names starting with TAGNAME. '
30 30
                          'Can be specified more than once')
31 31
 
32
+parser.add_argument('--ignore-snapname', metavar='TAGNAME', type=str, action='append',
33
+                    help='Do not consider snapshot names starting with TAGNAME. '
34
+                         'Can be specified more than once')
35
+
32 36
 parser.add_argument('-c', '--cache-dir', metavar="DIR",
33 37
                     help='First create a temporary file in directory DIR with the `zfs send` stream, '
34 38
                          'then rsync that to the remote host. With that, one can resume '
... ...
@@ -78,6 +82,14 @@ def select_snapshots(proc, prefix):
78 82
                    "expected a string starting with \"{1}\"").format(fs, prefix), file=sys.stderr)
79 83
             raise SystemExit(1)
80 84
         fs = fs[len(prefix):]
85
+        ignore = False
86
+        if args.ignore_snapname:
87
+            for ignore_snapname in args.ignore_snapname:
88
+                if snapname.startswith(ignore_snapname):
89
+                    ignore = True
90
+                    break
91
+        if ignore:
92
+            continue
81 93
         if args.snapname:
82 94
             for allowed_snapname in args.snapname:
83 95
                 if snapname.startswith(allowed_snapname):