From d77cfdf4c75688f1732be9b6272d1124cedb1f51 Mon Sep 17 00:00:00 2001 From: Christoph Klaffl Date: Fri, 1 May 2020 17:20:07 +0200 Subject: [PATCH 1/2] implemented option for keeping sync snaps --- syncoid | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/syncoid b/syncoid index 2eef326..702b1c3 100755 --- a/syncoid +++ b/syncoid @@ -25,7 +25,7 @@ GetOptions(\%args, "no-command-checks", "monitor-version", "compress=s", "dumpsn "source-bwlimit=s", "target-bwlimit=s", "sshkey=s", "sshport=i", "sshcipher|c=s", "sshoption|o=s@", "debug", "quiet", "no-stream", "no-sync-snap", "no-resume", "exclude=s@", "skip-parent", "identifier=s", "no-clone-handling", "no-privilege-elevation", "force-delete", "no-clone-rollback", "no-rollback", - "create-bookmark", "pv-options=s" => \$pvoptions, + "create-bookmark", "pv-options=s" => \$pvoptions, "keep-sync-snap", "mbuffer-size=s" => \$mbuffer_size) or pod2usage(2); my %compressargs = %{compressargset($args{'compress'} || 'default')}; # Can't be done with GetOptions arg, as default still needs to be set @@ -837,9 +837,11 @@ sub syncdataset { }; } } else { - # prune obsolete sync snaps on source and target (only if this run created ones). - pruneoldsyncsnaps($sourcehost,$sourcefs,$newsyncsnap,$sourceisroot,keys %{ $snaps{'source'}}); - pruneoldsyncsnaps($targethost,$targetfs,$newsyncsnap,$targetisroot,keys %{ $snaps{'target'}}); + if (!defined $args{'keep-sync-snap'}) { + # prune obsolete sync snaps on source and target (only if this run created ones). + pruneoldsyncsnaps($sourcehost,$sourcefs,$newsyncsnap,$sourceisroot,keys %{ $snaps{'source'}}); + pruneoldsyncsnaps($targethost,$targetfs,$newsyncsnap,$targetisroot,keys %{ $snaps{'target'}}); + } } } # end syncdataset() From 9ab57e9bb437c8f3857c88a94779c96c13c67e19 Mon Sep 17 00:00:00 2001 From: Christoph Klaffl Date: Fri, 1 May 2020 17:26:54 +0200 Subject: [PATCH 2/2] added documentation regarding --keep-sync-snap option --- README.md | 8 ++++++-- syncoid | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2b502b..89ddd4a 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,7 @@ As of 1.4.18, syncoid also automatically supports and enables resume of interrup + --source-bwlimit - This is the bandwidth limit in bytes (kbytes, mbytes, etc) per second imposed upon the source. This is mainly used if the target does not have mbuffer installed, but bandwidth limits are desired. + This is the bandwidth limit in bytes (kbytes, mbytes, etc) per second imposed upon the source. This is mainly used if the target does not have mbuffer installed, but bandwidth limits are desired. + --target-bw-limit @@ -210,9 +210,13 @@ As of 1.4.18, syncoid also automatically supports and enables resume of interrup This argument tells syncoid to restrict itself to existing snapshots, instead of creating a semi-ephemeral syncoid snapshot at execution time. Especially useful in multi-target (A->B, A->C) replication schemes, where you might otherwise accumulate a large number of foreign syncoid snapshots. ++ --keep-sync-snap + + This argument tells syncoid to skip pruning old snapshots created and used by syncoid for replication if '--no-sync-snap' isn't specified. + + --create-bookmark - This argument tells syncoid to create a zfs bookmark for the newest snapshot after it got replicated successfully. The bookmark name will be equal to the snapshot name. Only works in combination with the --no-sync-snap option. This can be very useful for irregular replication where the last matching snapshot on the source was already deleted but the bookmark remains so a replication is still possible. + This argument tells syncoid to create a zfs bookmark for the newest snapshot after it got replicated successfully. The bookmark name will be equal to the snapshot name. Only works in combination with the --no-sync-snap option. This can be very useful for irregular replication where the last matching snapshot on the source was already deleted but the bookmark remains so a replication is still possible. + --no-clone-rollback diff --git a/syncoid b/syncoid index 702b1c3..d9be7b4 100755 --- a/syncoid +++ b/syncoid @@ -1903,6 +1903,7 @@ Options: --pv-options=OPTIONS Configure how pv displays the progress bar, default '-p -t -e -r -b' --no-stream Replicates using newest snapshot instead of intermediates --no-sync-snap Does not create new snapshot, only transfers existing + --keep-sync-snap Don't destroy created sync snapshots --create-bookmark Creates a zfs bookmark for the newest snapshot on the source after replication succeeds (only works with --no-sync-snap) --no-clone-rollback Does not rollback clones on target --no-rollback Does not rollback clones or snapshots on target (it probably requires a readonly target)