Browse code

Allow multiple --snapname arguments

Lorenz H├╝depohl authored on 25/11/2017 19:34:19
Showing 1 changed files
... ...
@@ -27,8 +27,9 @@ parser.add_argument('destination', type=str,
27 27
                     help='Destination prefix, e.g. backup_pool/this_host. The ZFS snapshots from "origin" '
28 28
                          'are then stored below there. As with "origin", can be an SSH remote path')
29 29
 
30
-parser.add_argument('--snapname', metavar='TAGNAME', type=str,
31
-                    help='Only consider snapshots starting with TAGNAME')
30
+parser.add_argument('--snapname', metavar='TAGNAME', type=str, action='append',
31
+                    help='Only consider snapshot names starting with TAGNAME. '
32
+                         'Can be specified more than once')
32 33
 
33 34
 parser.add_argument('-c', '--cache-dir', metavar="DIR",
34 35
                     help='First create a temporary file in directory DIR with the `zfs send` stream, '
... ...
@@ -74,8 +75,10 @@ def select_snapshots(proc, prefix):
74 75
             raise SystemExit(1)
75 76
         fs = fs[len(prefix):]
76 77
         if args.snapname:
77
-            if snapname.startswith(args.snapname):
78
-                res.append((fs, snapname))
78
+            for allowed_snapname in args.snapname:
79
+                if snapname.startswith(allowed_snapname):
80
+                    res.append((fs, snapname))
81
+                    break
79 82
         else:
80 83
             res.append((fs, snapname))
81 84
     proc.wait()