Browse code

New option "-F" to force rollback to last snapshot

Lorenz Hüdepohl authored on 30/11/2017 19:48:28
Showing 1 changed files
... ...
@@ -49,6 +49,10 @@ parser.add_argument('-n', '--dry-run', action="store_true",
49 49
                     help='Only echo the transfer commands that would be issued,\n'
50 50
                          'do not actually send anything.')
51 51
 
52
+parser.add_argument('-F', '--force', action="store_true",
53
+                    help='Pass `-F` to `zfs receive` to Only echo the transfer commands that would be issued,\n'
54
+                         'do not actually send anything.')
55
+
52 56
 args = parser.parse_args()
53 57
 args.verbose = sum(args.verbose) if args.verbose is not None else 0
54 58
 
... ...
@@ -118,6 +122,11 @@ if args.verbose > 1:
118 122
 else:
119 123
     verbose = []
120 124
 
125
+if args.force:
126
+    force = ["-F"]
127
+else:
128
+    force = []
129
+
121 130
 with Popen(ssh_dest + ["zfs", "list", "-t", "snapshot", "-r", destination, "-H"], stdout=PIPE, stderr=PIPE) as proc:
122 131
     # Split into chunks for each fs
123 132
     destinations = {}
... ...
@@ -290,7 +299,7 @@ for fs, snapname in origin_snapshots:
290 299
     if use_cache_dir:
291 300
         pre_pipe = ["cat", dest_cache_filename, "|"] + pre_pipe
292 301
 
293
-    receive_cmd = ssh_dest + pre_pipe + ["zfs", "receive"] + verbose + ["-u", destination + fs]
302
+    receive_cmd = ssh_dest + pre_pipe + ["zfs", "receive"] + force + verbose + ["-u", destination + fs]
294 303
 
295 304
     send_shell = not ssh_orig
296 305
     if send_shell: