From d075800ac893fc51619898234f5771ecf4da6863 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 2 Jun 2024 20:19:29 +0200 Subject: [PATCH] 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 " )