Skip to content

Commit

Permalink
stored: ensure NDMP restore works with autoxflate
Browse files Browse the repository at this point in the history
When doing an NDMP restore the data must be sent to the client inflated.
This patch changes the autoxflate initialization so that an incompatible
configuration, that might send compressed data to the client, will be
overridden with safe defaults.
  • Loading branch information
arogge committed Feb 24, 2022
1 parent 3be6ab6 commit b8b4a4d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
18 changes: 16 additions & 2 deletions core/src/plugins/stored/autoxflate/autoxflate-sd.cc
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2013-2014 Planets Communications B.V.
Copyright (C) 2013-2021 Bareos GmbH & Co. KG
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand All @@ -25,6 +25,7 @@
* Storage Daemon plugin that handles automatic deflation/inflation of data.
*/
#include "include/bareos.h"
#include "include/protocol_types.h"
#include "stored/stored.h"
#include "stored/device_control_record.h"

Expand Down Expand Up @@ -309,7 +310,20 @@ static bRC setup_record_translation(PluginContext* ctx, void* value)

// Unpack the arguments passed in.
dcr = (DeviceControlRecord*)value;
if (!dcr) { return bRC_Error; }
if (!dcr || !dcr->jcr) { return bRC_Error; }

// When doing NDMP restore we must inflate the data before sending it to the
// client. Thus, if configured differently, we enforce the required settings.
if (dcr->jcr->getJobProtocol() == PT_NDMP_BAREOS
&& dcr->jcr->is_JobType(JT_RESTORE)
&& (AutoxflateModeContainsIn(dcr->autodeflate)
|| !AutoxflateModeContainsIn(dcr->autoinflate))) {
dcr->autoinflate = AutoXflateMode::IO_DIRECTION_IN;
dcr->autodeflate = AutoXflateMode::IO_DIRECTION_NONE;
Jmsg(ctx, M_INFO,
_("autoxflate-sd: overriding settings on %s for NDMP restore\n"),
dcr->dev_name);
}

// Give jobmessage info what is configured
switch (dcr->autodeflate) {
Expand Down
Expand Up @@ -8,7 +8,6 @@ Device {
RemovableMedia = no;
AlwaysOpen = no;
Description = "File device. A connecting Director must have the same Name and MediaType."
Auto Inflate = in
Auto Deflate = out
Auto Deflate Algorithm = gzip

Expand Down
Expand Up @@ -8,7 +8,6 @@ Device {
RemovableMedia = no;
AlwaysOpen = no;
Description = "File device. A connecting Director must have the same Name and MediaType."
Auto Inflate = in
Auto Deflate = out
Auto Deflate Algorithm = gzip

Expand Down

0 comments on commit b8b4a4d

Please sign in to comment.