Skip to content

Commit 4bfc696

Browse files
committed
chage for admin in separate folder
1 parent e0a4bed commit 4bfc696

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

mongodb_consistent_backup/Archive/Tar/TarThread.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,22 @@ def run(self):
3030
try:
3131
backup_base_dir = os.path.dirname(self.backup_dir)
3232
backup_base_name = os.path.basename(self.backup_dir)
33+
admin_backup_file = "_".join("admin",self.output_file)
3334

3435
log_msg = "Archiving directory: %s" % self.backup_dir
35-
cmd_flags = ["-C", backup_base_dir, "-c", "-f", self.output_file, "--remove-files"]
36+
cmd_flags = ["-C", backup_base_dir, "-c", "-f", self.output_file, "--exclude", "admin" ,"--remove-files"]
37+
admin_cmd_flags = ["-C", backup_base_dir, "-c", "-f", admin_backup_file, "admin", "--remove-files"]
38+
3639

3740
if self.do_gzip():
3841
log_msg = "Archiving and compressing directory: %s" % self.backup_dir
3942
cmd_flags.append("-z")
43+
admin_cmd_flags.append("-z")
4044

4145
cmd_flags.append(backup_base_name)
4246
logging.info(log_msg)
4347
self.running = True
44-
self._command = LocalCommand(self.binary, cmd_flags, self.verbose)
48+
self._command = LocalCommand(self.binary, cmd_flags, admin_cmd_flags, self.verbose)
4549
self.exit_code = self._command.run()
4650
except Exception, e:
4751
return self.result(False, "Failed archiving file: %s!" % self.output_file, e)

mongodb_consistent_backup/Backup/Mongodump/MongodumpThread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def mongodump_cmd(self):
173173
logging.info("MongoDump Version higher that 4.2.0 found extending mongodump with snppy compressor flag")
174174
## https://www.mongodb.com/docs/drivers/node/v4.4/fundamentals/connection/network-compression/
175175
mongodump_flags.extend([
176-
"--compressors=%s" % "snappy,zlib,zstd"
176+
"--compressors=%s" % "zstd,snappy,zlib"
177177
])
178178

179179
# --numParallelCollections

mongodb_consistent_backup/Common/LocalCommand.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77

88

99
class LocalCommand:
10-
def __init__(self, command, command_flags=None, verbose=False):
10+
def __init__(self, command, command_flags=None, admin_cmd_flags=None, verbose=False):
1111
if command_flags is None:
1212
command_flags = []
13+
if admin_command_flags is None:
14+
admin_command_flags = []
1315
self.command = command
1416
self.command_flags = command_flags
17+
self.admin_command_flags = command_flags
1518
self.verbose = verbose
1619

1720
self.output = []
@@ -21,6 +24,10 @@ def __init__(self, command, command_flags=None, verbose=False):
2124
if len(self.command_flags):
2225
self.command_line.extend(self.command_flags)
2326

27+
self.admin_command_line = [self.command]
28+
if len(self.admin_command_flags):
29+
self.admin_command_line.extend(self.command_flags)
30+
2431
def parse_output(self):
2532
if self._process:
2633
try:
@@ -36,7 +43,7 @@ def parse_output(self):
3643

3744
def run(self):
3845
try:
39-
self._process = Popen(self.command_line, stdout=PIPE, stderr=PIPE)
46+
self._process = Popen(self.command_line+" && "+ self.admin_command_line, stdout=PIPE, stderr=PIPE)
4047
while self._process.poll() is None:
4148
self.parse_output()
4249
sleep(0.1)

0 commit comments

Comments
 (0)