@@ -152,11 +152,18 @@ def run(self):
152152 except Exception , e :
153153 raise e
154154
155+ # Setup the archiver
156+ try :
157+ self .archive = Archive (
158+ self .config ,
159+ self .backup_root_directory ,
160+ )
161+ except Exception , e :
162+ raise e
163+
155164 if not self .is_sharded :
156165 logging .info ("Running backup of %s:%s in replset mode" % (self .config .host , self .config .port ))
157166
158- self .config .archive .threads = 1
159-
160167 # get shard secondary
161168 try :
162169 self .replset = Replset (
@@ -179,12 +186,13 @@ def run(self):
179186 )
180187 self .backup .backup ()
181188 if self .backup .is_compressed ():
182- logging .info ("Backup method supports gzip compression, setting config overrides: { archive.compression: 'none' }" )
183- self .config .archive .compression = 'none'
184- self .config .oplog .compression = 'gzip'
189+ logging .info ("Backup method supports gzip compression, disabling compression in archive step" )
190+ self .archive .compression ('none' )
185191 except Exception , e :
186192 self .exception ("Problem performing replset mongodump! Error: %s" % e )
187193
194+ # use 1 archive thread for single replset
195+ self .archive .threads (1 )
188196 else :
189197 logging .info ("Running backup of %s:%s in sharded mode" % (self .config .host , self .config .port ))
190198
@@ -215,6 +223,16 @@ def run(self):
215223 except Exception , e :
216224 self .exception ("Problem stopping the balancer! Error: %s" % e )
217225
226+ # init the oplogtailers
227+ try :
228+ self .oplogtailer = Tailer (
229+ self .config ,
230+ self .secondaries ,
231+ self .backup_root_directory
232+ )
233+ except Exception , e :
234+ self .exception ("Problem initializing oplog tailer! Error: %s" % e )
235+
218236 # init the backup
219237 try :
220238 self .backup = Backup (
@@ -224,19 +242,14 @@ def run(self):
224242 self .sharding .get_config_server ()
225243 )
226244 if self .backup .is_compressed ():
227- logging .info ("Backup method supports gzip compression, setting config overrides: { archive.compression: 'none', oplog.compression: 'gzip' } " )
228- self .config . archive .compression = 'none'
229- self .config . oplog . compression = 'gzip'
245+ logging .info ("Backup method supports gzip compression, disabling compression in archive step and enabling oplog compression " )
246+ self .archive .compression ( 'none' )
247+ self .oplogtailer . compression ( 'gzip' )
230248 except Exception , e :
231249 self .exception ("Problem initializing backup! Error: %s" % e )
232250
233- # start the oplog tailer(s)
251+ # start the oplog tailers, before the backups start
234252 try :
235- self .oplogtailer = Tailer (
236- self .config ,
237- self .secondaries ,
238- self .backup_root_directory
239- )
240253 self .oplogtailer .run ()
241254 except Exception , e :
242255 self .exception ("Failed to start oplog tailing threads! Error: %s" % e )
@@ -264,10 +277,6 @@ def run(self):
264277
265278 # archive backup directories
266279 try :
267- self .archive = Archive (
268- self .config ,
269- self .backup_root_directory ,
270- )
271280 self .archive .archive ()
272281 except Exception , e :
273282 self .exception ("Problem performing archiving! Error: %s" % e )
0 commit comments