Skip to content

Check if Backup/Mongodump.py 'auto' compress mode can actually support compression (#193) #210

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

Merged
merged 2 commits into from
Sep 20, 2017
Merged
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
6 changes: 3 additions & 3 deletions mongodb_consistent_backup/Backup/Mongodump/Mongodump.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ def parse_mongodump_version(self):
raise OperationError("Could not parse mongodump --version output!")

def choose_compression(self):
if self.can_gzip():
if self.can_compress():
if self.compression() == 'auto':
logging.info("Mongodump binary supports gzip compression, auto-enabling gzip compression")
self.compression('gzip')
elif self.compression() == 'gzip':
raise OperationError("mongodump gzip compression requested on binary that does not support gzip!")

def can_gzip(self):
def can_compress(self):
if os.path.isfile(self.binary) and os.access(self.binary, os.X_OK):
logging.debug("Mongodump binary supports gzip")
logging.debug("Mongodump binary supports gzip compression")
if tuple("3.2.0".split(".")) <= tuple(self.version.split(".")):
return True
return False
Expand Down
1 change: 1 addition & 0 deletions mongodb_consistent_backup/Pipeline/Stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def close(self):
def is_compressed(self):
if self.has_task() and hasattr(self._task, "is_compressed"):
return self._task.is_compressed()
return False

def compression(self, task=None):
if self.has_task() and hasattr(self._task, "compression"):
Expand Down
4 changes: 3 additions & 1 deletion mongodb_consistent_backup/Pipeline/Task.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def compression(self, method=None):
return parse_method(self.compression_method)

def is_compressed(self):
if self.compression() != 'none':
if self.compression() == 'auto' and hasattr(self, "can_compress"):
return self.can_compress()
elif self.compression() != 'none':
return True
return False

Expand Down