diff --git a/bin/zfs-autobackup b/bin/zfs-autobackup index 036ed81..4134c86 100755 --- a/bin/zfs-autobackup +++ b/bin/zfs-autobackup @@ -1565,7 +1565,7 @@ class ZfsAutobackup: # parser.add_argument('--ignore-new', action='store_true', help='Ignore filesystem if there are already newer snapshots for it on the target (use with caution)') parser.add_argument('--resume', action='store_true', help=argparse.SUPPRESS) - parser.add_argument('--strip-path', default=0, type=int, help='Number of directory to strip from path (use 1 when cloning zones between 2 SmartOS machines)') + parser.add_argument('--strip-path', default=0, type=int, help='Number of directories to strip from target path (use 1 when cloning zones between 2 SmartOS machines)') # parser.add_argument('--buffer', default="", help='Use mbuffer with specified size to speedup zfs transfer. (e.g. --buffer 1G) Will also show nice progress output.') diff --git a/test_zfsautobackup.py b/test_zfsautobackup.py index 381c212..254d528 100644 --- a/test_zfsautobackup.py +++ b/test_zfsautobackup.py @@ -264,3 +264,65 @@ test_target1/test_source2/fs2 test_target1/test_source2/fs2/sub test_target1/test_source2/fs2/sub@test-20101111000000 """) + + def test_noholds(self): + + with patch('time.strftime', return_value="20101111000000"): + self.assertFalse(ZfsAutobackup("test test_target1 --verbose --no-holds".split(" ")).run()) + + r=shelltest("zfs get -r userrefs test_source1 test_source2 test_target1") + self.assertMultiLineEqual(r,""" +NAME PROPERTY VALUE SOURCE +test_source1 userrefs - - +test_source1/fs1 userrefs - - +test_source1/fs1@test-20101111000000 userrefs 0 - +test_source1/fs1/sub userrefs - - +test_source1/fs1/sub@test-20101111000000 userrefs 0 - +test_source2 userrefs - - +test_source2/fs2 userrefs - - +test_source2/fs2/sub userrefs - - +test_source2/fs2/sub@test-20101111000000 userrefs 0 - +test_source2/fs3 userrefs - - +test_source2/fs3/sub userrefs - - +test_target1 userrefs - - +test_target1/test_source1 userrefs - - +test_target1/test_source1/fs1 userrefs - - +test_target1/test_source1/fs1@test-20101111000000 userrefs 1 - +test_target1/test_source1/fs1/sub userrefs - - +test_target1/test_source1/fs1/sub@test-20101111000000 userrefs 1 - +test_target1/test_source2 userrefs - - +test_target1/test_source2/fs2 userrefs - - +test_target1/test_source2/fs2/sub userrefs - - +test_target1/test_source2/fs2/sub@test-20101111000000 userrefs 1 - +""") + + + def test_strippath(self): + + with patch('time.strftime', return_value="20101111000000"): + self.assertFalse(ZfsAutobackup("test test_target1 --verbose --strip-path=1".split(" ")).run()) + + r=shelltest("zfs list -H -o name -r -t all") + self.assertMultiLineEqual(r,""" +test_source1 +test_source1/fs1 +test_source1/fs1@test-20101111000000 +test_source1/fs1/sub +test_source1/fs1/sub@test-20101111000000 +test_source2 +test_source2/fs2 +test_source2/fs2/sub +test_source2/fs2/sub@test-20101111000000 +test_source2/fs3 +test_source2/fs3/sub +test_target1 +test_target1/fs1 +test_target1/fs1@test-20101111000000 +test_target1/fs1/sub +test_target1/fs1/sub@test-20101111000000 +test_target1/fs2 +test_target1/fs2/sub +test_target1/fs2/sub@test-20101111000000 +""") + +