From d99c202e75dbc010ee6f8a312434b656f0d3e288 Mon Sep 17 00:00:00 2001 From: Edwin Eefting Date: Wed, 23 Feb 2022 21:21:07 +0100 Subject: [PATCH] fix --- tests/test_zfsautobackup31.py | 16 ++++++++++++++++ zfs_autobackup/ZfsAutobackup.py | 2 ++ 2 files changed, 18 insertions(+) diff --git a/tests/test_zfsautobackup31.py b/tests/test_zfsautobackup31.py index 4d56856..1f89a07 100644 --- a/tests/test_zfsautobackup31.py +++ b/tests/test_zfsautobackup31.py @@ -79,3 +79,19 @@ test_target1/b/test_target1/a/test_source1/fs1/sub@test-20101111000000 self.assertFalse( ZfsAutobackup("test test_target1 --no-progress --verbose --debug --zfs-compressed".split(" ")).run()) + def test_force(self): + """test 1:1 replication""" + + shelltest("zfs set autobackup:test=true test_source1") + + with patch('time.strftime', return_value="test-20101111000000"): + self.assertFalse( + ZfsAutobackup("test test_target1 --no-progress --verbose --debug --force --strip-path=1".split(" ")).run()) + + r=shelltest("zfs list -H -o name -r -t snapshot test_target1") + self.assertMultiLineEqual(r,""" +test_target1@test-20101111000000 +test_target1/fs1@test-20101111000000 +test_target1/fs1/sub@test-20101111000000 +test_target1/fs2/sub@test-20101111000000 +""") diff --git a/zfs_autobackup/ZfsAutobackup.py b/zfs_autobackup/ZfsAutobackup.py index 5f58212..a6f1412 100644 --- a/zfs_autobackup/ZfsAutobackup.py +++ b/zfs_autobackup/ZfsAutobackup.py @@ -91,6 +91,8 @@ class ZfsAutobackup(ZfsAuto): group.add_argument('--rollback', action='store_true', help='Rollback changes to the latest target snapshot before starting. (normally you can ' 'prevent changes by setting the readonly property on the target_path to on)') + group.add_argument('--force', '-F', action='store_true', + help='Use zfs -F option to force overwrite/rollback. (Usefull with --strip-path=1, but use with care)') group.add_argument('--destroy-incompatible', action='store_true', help='Destroy incompatible snapshots on target. Use with care! (implies --rollback)') group.add_argument('--ignore-transfer-errors', action='store_true',