Skip to content

Commit b08aaf3

Browse files
authored
[M6-473] chage for admin in separate folder (#12)
[M6-473] change for admin in separate folder
1 parent e0a4bed commit b08aaf3

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,6 @@ Contact
256256
~~~~~~~
257257

258258
`Contact Percona <mailto:[email protected]>`__
259+
260+
Take Bacup OR Instances:
261+
rocket_consistent_backup_wrapper `instaneid`

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.2
1+
1.4.3

mongodb_consistent_backup/Archive/Tar/TarThread.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import logging
33

4+
45
from mongodb_consistent_backup.Common import LocalCommand
56
from mongodb_consistent_backup.Pipeline import PoolThread
67

@@ -30,18 +31,25 @@ def run(self):
3031
try:
3132
backup_base_dir = os.path.dirname(self.backup_dir)
3233
backup_base_name = os.path.basename(self.backup_dir)
34+
output_file_dir = os.path.dirname(self.output_file)
35+
output_file_basename= os.path.basename(self.output_file)
36+
admin_backup_file = output_file_dir+"/" +"_".join(["admin",output_file_basename])
3337

3438
log_msg = "Archiving directory: %s" % self.backup_dir
35-
cmd_flags = ["-C", backup_base_dir, "-c", "-f", self.output_file, "--remove-files"]
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"]
41+
3642

3743
if self.do_gzip():
3844
log_msg = "Archiving and compressing directory: %s" % self.backup_dir
3945
cmd_flags.append("-z")
46+
admin_command_flags.append("-z")
4047

4148
cmd_flags.append(backup_base_name)
49+
admin_command_flags.append("admin")
4250
logging.info(log_msg)
4351
self.running = True
44-
self._command = LocalCommand(self.binary, cmd_flags, self.verbose)
52+
self._command = LocalCommand(self.binary, cmd_flags, admin_command_flags, self.verbose)
4553
self.exit_code = self._command.run()
4654
except Exception, e:
4755
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: 10 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_command_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 = admin_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.admin_command_flags)
30+
2431
def parse_output(self):
2532
if self._process:
2633
try:
@@ -36,7 +43,8 @@ def parse_output(self):
3643

3744
def run(self):
3845
try:
39-
self._process = Popen(self.command_line, stdout=PIPE, stderr=PIPE)
46+
cmd = " ".join(self.admin_command_line+ ["&&"]+ self.command_line)
47+
self._process = Popen(cmd, stdout=PIPE, stderr=PIPE,shell= True)
4048
while self._process.poll() is None:
4149
self.parse_output()
4250
sleep(0.1)

0 commit comments

Comments
 (0)