Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail on missing clone #817

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,18 @@ As of 1.4.18, syncoid also automatically supports and enables resume of interrup

This argument tells syncoid to not recreate clones on the target on initial sync, and do a normal replication instead.

+ --no-full-clone
Only applies to recursive transfer when clone handling is active.
In case a clone origin is missing (on destination) because its transfer was interrupted
don't switch to a full clone sync.
Example worst case scenario this may help prevent:
A 1TB dataset has 500 identical clones. Overall it uses just 1 TB storage space at the source, because
all clone share the storage with origin.
Assume a recursive transfer is started that needs to send all datasets (origin and 500 clones).
Assume also the origin dataset transfer ends up failing. Without selecting this option, the recursive
transfer proceeds to next recursive dataset, and because origin is missing (receive not completed),
each clone becomes a full clone and we end up trying to transfer 500TB !

+ --dumpsnaps

This prints a list of snapshots during the run.
Expand Down
16 changes: 13 additions & 3 deletions syncoid
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ GetOptions(\%args, "no-command-checks", "monitor-version", "compress=s", "dumpsn
"source-bwlimit=s", "target-bwlimit=s", "sshconfig=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-rollback", "create-bookmark",
"pv-options=s" => \$pvoptions, "keep-sync-snap", "preserve-recordsize", "mbuffer-size=s" => \$mbuffer_size)
"pv-options=s" => \$pvoptions, "keep-sync-snap", "preserve-recordsize", "mbuffer-size=s" => \$mbuffer_size, "no-full-clone")
or pod2usage(2);

my %compressargs = %{compressargset($args{'compress'} || 'default')}; # Can't be done with GetOptions arg, as default still needs to be set
Expand Down Expand Up @@ -183,6 +183,10 @@ if (!defined $args{'recursive'}) {
}

if ($found == 0) {
if (defined $args{'no-full-clone'}) {
print("SKIPPING: $dataset because origin clone is missing. Retry running syncoid.\n");
next;
}
# clone source is not replicated, do a full replication
$origin = undef;
} else {
Expand Down Expand Up @@ -491,8 +495,13 @@ sub syncdataset {
system($synccmd) == 0 or do {
if (defined $origin) {
print "INFO: clone creation failed, trying ordinary replication as fallback\n";
syncdataset($sourcehost, $sourcefs, $targethost, $targetfs, undef, 1);
return 0;
if (defined $args{'no-full-clone'}) {
print("SKIPPING: $synccmd because origin clone is missing. Retry running syncoid.\n");
# Fall through to normal error
} else {
syncdataset($sourcehost, $sourcefs, $targethost, $targetfs, undef, 1);
return 0;
}
}

warn "CRITICAL ERROR: $synccmd failed: $?";
Expand Down Expand Up @@ -2018,5 +2027,6 @@ Options:
--no-resume Don't use the ZFS resume feature if available
--no-clone-handling Don't try to recreate clones on target
--no-privilege-elevation Bypass the root check, for use with ZFS permission delegation
--no-full-clone Don't convert a clone into a full clone if the clone's origin is missing at destination

--force-delete Remove target datasets recursively, if there are no matching snapshots/bookmarks (also overwrites conflicting named snapshots)