From d2a1c5656476df78bcc48c0846657ffad4785a47 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 2 Jun 2024 19:04:22 +0200 Subject: [PATCH 1/4] lib/ZnapZend/Config.pm: dis-/enableBackupSetDstAutoCreation(): trace working or slacking off, and do not rely on existence of the property to set it [#650] Addresses the part of issue #650 where ./bin/znapzendzetup enable-dst-autocreation --debug test1 nas in fact did nothing. Signed-off-by: Jim Klimov --- lib/ZnapZend/Config.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ZnapZend/Config.pm b/lib/ZnapZend/Config.pm index 19b9dc6f..0fe602d0 100644 --- a/lib/ZnapZend/Config.pm +++ b/lib/ZnapZend/Config.pm @@ -270,7 +270,7 @@ my $checkBackupSets = sub { }; } } - #drop destination plans where destination is not given (e.g. calling create w/o a destination but a plan + #drop destination plans where destination is not given (e.g. calling create w/o a destination but a plan) for my $dst (grep { /^dst_[^_]+_plan$/ } keys %$backupSet){ $dst =~ s/_plan//; #remove trailing '_plan' so we get destination @@ -572,9 +572,8 @@ sub enableBackupSetDstAutoCreation { } if ($cfg{$dest}) { - if ($cfg{$dest . '_autocreation'}) { - $cfg{$dest . '_autocreation'} = 'on'; - } + $self->zLog->debug("#enableBackupSetDstAutoCreation# applying to dest=$dest of $dataSet backup plan") if $self->debug; + $cfg{$dest . '_autocreation'} = 'on'; } else { die "ERROR: dataset $dataSet backup plan does not have destination $dest\n"; } @@ -583,6 +582,7 @@ sub enableBackupSetDstAutoCreation { return 1; } + $self->zLog->debug("#enableBackupSetDstAutoCreation# found no backupSets for $dataSet backup plan") if $self->debug; return 0; } @@ -618,6 +618,7 @@ sub disableBackupSetDstAutoCreation { } if ($cfg{$dest}) { + $self->zLog->debug("#disableBackupSetDstAutoCreation# applying to dest=$dest of $dataSet backup plan") if $self->debug; $cfg{$dest . '_autocreation'} = 'off'; } else { die "ERROR: dataset $dataSet backup plan does not have destination $dest\n"; @@ -627,6 +628,7 @@ sub disableBackupSetDstAutoCreation { return 1; } + $self->zLog->debug("#disableBackupSetDstAutoCreation# found no backupSets for $dataSet backup plan") if $self->debug; return 0; } From 49c9cb1f971b93162292dacbfd09e6c2bfc12626 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 2 Jun 2024 19:26:05 +0200 Subject: [PATCH 2/4] lib/ZnapZend/Config.pm: checkBackupSets(): report also backupSetKeysFilteredAway in the log, to avoid confusion [#650] Signed-off-by: Jim Klimov --- lib/ZnapZend/Config.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ZnapZend/Config.pm b/lib/ZnapZend/Config.pm index 0fe602d0..dde559d2 100644 --- a/lib/ZnapZend/Config.pm +++ b/lib/ZnapZend/Config.pm @@ -112,11 +112,16 @@ my $checkBackupSets = sub { # tags are user-provided and not too predictable), so only "src" # would remain there: my @backupSetKeysFiltered = grep (!/^dst_[^_]+_autocreation$/, keys(%{$backupSet})); + my @backupSetKeysFilteredAway = grep (/^dst_[^_]+_autocreation$/, keys(%{$backupSet})); my $backupSetKeysFiltered = scalar(@backupSetKeysFiltered); + my $backupSetKeysFilteredAway = scalar(@backupSetKeysFilteredAway); $self->zLog->debug("#checkBackupSets# backupSetKeysFiltered " . "for '" . $backupSet->{src} . "' = (" . $backupSetKeysFiltered . ")[" - . join(", ", @backupSetKeysFiltered) . "]" + . join(", ", @backupSetKeysFiltered) . "] " + . "and backupSetKeysFilteredAway (not impacting some of the checks) = (" + . $backupSetKeysFilteredAway . ")[" + . join(", ", @backupSetKeysFilteredAway) . "]" ) if $self->debug; # "src" and "enabled", or "src" alone (after disregarding autocreation): From d075800ac893fc51619898234f5771ecf4da6863 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 2 Jun 2024 20:19:29 +0200 Subject: [PATCH 3/4] lib/ZnapZend.pm: sendRecvCleanup(): reconcile sendRaw and autoCreation condition clause when a destination sub-dataset is missing [#650] Signed-off-by: Jim Klimov --- lib/ZnapZend.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/ZnapZend.pm b/lib/ZnapZend.pm index 4517e91d..38e33525 100644 --- a/lib/ZnapZend.pm +++ b/lib/ZnapZend.pm @@ -420,6 +420,9 @@ my $refreshBackupPlans = sub { $backupSet->{"dst_$key" . '_valid'} = $self->zZfs->dataSetExists($backupSet->{"dst_$key"}) or do { + # Do not automatically create destination when using + # feature sendRaw, receiving a raw encrypted stream + # is not supported on unencrypted datasets if ($autoCreation && !$self->sendRaw) { my ($zpool) = $backupSet->{"dst_$key"} =~ /(^[^\/]+)\//; @@ -588,6 +591,9 @@ my $sendRecvCleanup = sub { $backupSet->{"dst_$key" . '_valid'} = $self->zZfs->dataSetExists($backupSet->{"dst_$key"}) or do { + # Do not automatically create destination when using + # feature sendRaw, receiving a raw encrypted stream + # is not supported on unencrypted datasets if ($autoCreation && !$self->sendRaw) { my ($zpool) = $backupSet->{"dst_$key"} =~ /(^[^\/]+)\//; @@ -606,6 +612,8 @@ my $sendRecvCleanup = sub { } }; } + # TOTHINK: Is the sendRaw comparison correct here for the intent + # and purpose of PR https://github.com/oetiker/znapzend/pull/496 ? ( $backupSet->{"dst_$key" . '_valid'} || ($self->sendRaw && $autoCreation) ) or do { my $errmsg = "destination '" . $backupSet->{"dst_$key"} . "' does not exist or is offline; ignoring it for this round..."; @@ -664,7 +672,10 @@ my $sendRecvCleanup = sub { # Time to check if the target sub-dataset exists # at all (unless we would auto-create one anyway). - if ((!$autoCreation || !$self->sendRaw) && !($self->zZfs->dataSetExists($dstDataSet))) { + # Do not automatically create destination when using + # feature sendRaw, receiving a raw encrypted stream + # is not supported on unencrypted datasets. + if ((!$autoCreation || $self->sendRaw) && !($self->zZfs->dataSetExists($dstDataSet))) { my $errmsg = "sub-destination '" . $dstDataSet . "' does not exist or is offline; ignoring it for this round... Consider " . ( $autoCreation || $self->sendRaw ? "" : "running znapzend --autoCreation or " ) From 95515b9d71008aa3a3b1793bc592969a55baaf36 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 2 Jun 2024 20:29:02 +0200 Subject: [PATCH 4/4] Update CHANGES --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 1413f80a..602efe10 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,4 @@ + * Fixed `autoCreation` behavior broken in 0.22.0 release -- @jimklimov * Updated recipes for `make check` to install Perl modules it needs (previously was only done as part of GitHub checks); renamed the `cpanfile` to `cpanfile.common` to avoid changing the Git-tracked