Skip to content

Commit ac861cd

Browse files
Merge pull request #85 from timvaillancourt/MCB_1.0-cleanup_v2
Mcb 1.0 cleanup v2
2 parents 1fef902 + cf37128 commit ac861cd

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

mongodb_consistent_backup/Archive/Tar/Tar.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@ def __init__(self, config, backup_base_dir):
2424
self.backup_base_dir = backup_base_dir
2525
self.verbose = self.config.verbose
2626
self.binary = "tar"
27-
self.do_gzip = False
2827
self._pool = None
2928

3029
def compression(self, method=None):
3130
if method:
3231
self.config.archive.tar.compression = method.lower()
32+
logging.info("Setting tar compression method to: %s" % self.config.archive.tar.compression)
3333
return self.config.archive.tar.compression
3434

35+
def do_gzip(self):
36+
if self.compression() == 'gzip':
37+
return True
38+
return False
39+
3540
def threads(self, thread_count=None):
3641
if thread_count:
3742
self.config.archive.tar.threads = int(thread_count)
@@ -55,11 +60,10 @@ def run(self):
5560
subdir_name = "%s/%s" % (self.backup_base_dir, backup_dir)
5661
output_file = "%s.tar" % subdir_name
5762

58-
if self.compression() == 'gzip':
63+
if self.do_gzip():
5964
output_file = "%s.tgz" % subdir_name
60-
self.do_gzip = True
6165

62-
self._pool.apply_async(TarThread(subdir_name, output_file, self.do_gzip, self.verbose, self.binary).run)
66+
self._pool.apply_async(TarThread(subdir_name, output_file, self.do_gzip(), self.verbose, self.binary).run)
6367
except Exception, e:
6468
self._pool.terminate()
6569
logging.fatal("Could not create archiving thread! Error: %s" % e)

mongodb_consistent_backup/Backup/Backup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,25 @@ def __init__(self, config, backup_dir, secondaries, config_server=None):
1010
self.secondaries = secondaries
1111
self.config_server = config_server
1212

13+
self.method = None
1314
self._method = None
1415
self.init()
1516

1617
def init(self):
1718
backup_method = self.config.backup.method
1819
if not backup_method or backup_method.lower() == "none":
1920
raise Exception, 'Must specify a backup method!', None
20-
method = backup_method.lower()
21-
logging.info("Using backup method: %s" % method)
21+
self.method = backup_method.lower()
22+
logging.info("Using backup method: %s" % self.method)
2223
try:
23-
self._method = globals()[method.capitalize()](
24+
self._method = globals()[self.method.capitalize()](
2425
self.config,
2526
self.backup_dir,
2627
self.secondaries,
2728
self.config_server
2829
)
2930
except Exception, e:
30-
raise Exception, "Problem performing %s! Error: %s" % (method, e), None
31+
raise Exception, "Problem performing %s! Error: %s" % (self.method, e), None
3132

3233
def is_compressed(self):
3334
if self._method:

mongodb_consistent_backup/Notify/Notify.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Notify:
44
def __init__(self, config):
55
self.config = config
66

7+
self.method = None
78
self._notifier = None
89
self.init()
910

@@ -12,10 +13,10 @@ def init(self):
1213
if not notify_method or notify_method.lower() == "none":
1314
logging.info("Notifying disabled, skipping")
1415
else:
15-
method = notify_method.lower()
16-
logging.info("Using notify method: %s" % method)
16+
self.method = notify_method.lower()
17+
logging.info("Using notify method: %s" % self.method)
1718
try:
18-
self._notifier = globals()[method.capitalize()](self.config)
19+
self._notifier = globals()[self.method.capitalize()](self.config)
1920
except Exception, e:
2021
raise e
2122

mongodb_consistent_backup/Oplog/Tailer/Tailer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(self, config, secondaries, base_dir):
2323
def compression(self, method=None):
2424
if method:
2525
self.config.oplog.compression = method.lower()
26+
logging.info("Setting oplog compression method to: %s" % self.config.oplog.compression)
2627
return self.config.oplog.compression
2728

2829
def do_gzip(self):

mongodb_consistent_backup/Upload/Upload.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def __init__(self, config, base_dir, backup_dir):
99
self.base_dir = base_dir
1010
self.backup_dir = backup_dir
1111

12+
self.method = None
1213
self._uploader = None
1314
self.init()
1415

@@ -17,19 +18,16 @@ def init(self):
1718
if not upload_method or upload_method.lower() == "none":
1819
logging.info("Uploading disabled, skipping")
1920
else:
20-
#TODO Remove this line and move to S3 Lib for checking
21-
# if self.config.upload.method == "s3" and self.config.upload.s3.bucket_name and self.config.upload.s3.bucket_prefix and self.config.upload.s3.access_key and self.config.upload.s3.secret_key:
22-
23-
method = upload_method.lower()
24-
logging.info("Using upload method: %s" % method)
21+
self.method = upload_method.lower()
22+
logging.info("Using upload method: %s" % self.method)
2523
try:
26-
self._uploader = globals()[method.capitalize()](
24+
self._uploader = globals()[self.method.capitalize()](
2725
self.config,
2826
self.base_dir,
2927
self.backup_dir
3028
)
3129
except Exception, e:
32-
raise Exception, "Problem settings up %s Uploader Error: %s" % (method, e), None
30+
raise Exception, "Problem settings up %s Uploader Error: %s" % (self.method, e), None
3331

3432
def upload(self):
3533
if self._uploader:

0 commit comments

Comments
 (0)