Skip to content

Commit 5a836e4

Browse files
authored
M6 492- separate config folder (#15)
Separate config, admin folder for each shard
1 parent 9d8ea84 commit 5a836e4

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.5
1+
1.4.6

mongodb_consistent_backup/Archive/Tar/TarThread.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,26 @@ def run(self):
3434
output_file_dir = os.path.dirname(self.output_file)
3535
output_file_basename= os.path.basename(self.output_file)
3636
admin_backup_file = output_file_dir+"/" +"_".join(["admin",output_file_basename])
37+
config_backup_file = output_file_dir+"/" +"_".join(["config",output_file_basename])
3738

3839
log_msg = "Archiving directory: %s" % self.backup_dir
39-
cmd_flags = ["--exclude", "admin" ,"-C", backup_base_dir, "-c", "-f", self.output_file, "--remove-files"]
40-
admin_command_flags = ["-C", self.backup_dir +"/dump/", "-c", "-f", admin_backup_file, "--remove-files"]
40+
cmd_flags = ["--exclude", "admin", "--exclude", "config" ,"-C", backup_base_dir, "-c", "-f", self.output_file, "--remove-files"]
41+
admin_command_flags = ["-C", self.backup_dir +"/dump/", "-c", "-f", admin_backup_file, "--remove-files", "--ignore-failed-read",]
42+
config_command_flags = ["-C", self.backup_dir +"/dump/", "-c", "-f", config_backup_file, "--remove-files", "--ignore-failed-read",]
4143

4244

4345
if self.do_gzip():
4446
log_msg = "Archiving and compressing directory: %s" % self.backup_dir
4547
cmd_flags.append("-z")
4648
admin_command_flags.append("-z")
49+
config_command_flags.append("-z")
4750

4851
cmd_flags.append(backup_base_name)
4952
admin_command_flags.append("admin")
53+
config_command_flags.append("config")
5054
logging.info(log_msg)
5155
self.running = True
52-
self._command = LocalCommand(self.binary, cmd_flags, admin_command_flags, self.verbose)
56+
self._command = LocalCommand(self.binary, cmd_flags, admin_command_flags, config_command_flags, self.verbose)
5357
self.exit_code = self._command.run()
5458
except Exception, e:
5559
return self.result(False, "Failed archiving file: %s!" % self.output_file, e)

mongodb_consistent_backup/Common/LocalCommand.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@
77

88

99
class LocalCommand:
10-
def __init__(self, command, command_flags=None, admin_command_flags=None, verbose=False):
10+
def __init__(self, command, command_flags=None, admin_command_flags=None, config_command_flags=None,verbose=False):
1111
if command_flags is None:
1212
command_flags = []
1313
if admin_command_flags is None:
1414
admin_command_flags = []
15+
if config_command_flags is None:
16+
config_command_flags = []
1517
self.command = command
1618
self.command_flags = command_flags
1719
self.admin_command_flags = admin_command_flags
18-
self.verbose = verbose
20+
self.config_command_flags = config_command_flags
21+
self.verbose = verbose
1922

2023
self.output = []
2124
self._process = None
@@ -27,6 +30,10 @@ def __init__(self, command, command_flags=None, admin_command_flags=None, verbos
2730
self.admin_command_line = [self.command]
2831
if len(self.admin_command_flags):
2932
self.admin_command_line.extend(self.admin_command_flags)
33+
self.config_command_line = [self.command]
34+
if len(self.config_command_flags):
35+
self.config_command_line.extend(self.config_command_flags)
36+
3037

3138
def parse_output(self):
3239
if self._process:
@@ -43,7 +50,7 @@ def parse_output(self):
4350

4451
def run(self):
4552
try:
46-
cmd = " ".join(["export GZIP=-1"]+ ["&&"] +self.admin_command_line+ ["&&"]+ self.command_line)
53+
cmd = " ".join(["export GZIP=-1" ]+ ["&&"] + self.admin_command_line + ["&&"] + self.config_command_line + ["&&"] + self.command_line)
4754
self._process = Popen(cmd, stdout=PIPE, stderr=PIPE,shell= True)
4855
while self._process.poll() is None:
4956
self.parse_output()

0 commit comments

Comments
 (0)