@@ -100,6 +100,24 @@ var dontPreserveUUID = []string{
100
100
"*.system.views" , // timeseries
101
101
}
102
102
103
+ // ConfigCollToKeep defines a list of collections in the `config`
104
+ // database that PBM will apply oplog events.
105
+ var configCollToKeep = []string {
106
+ "chunks" ,
107
+ "collections" ,
108
+ "databases" ,
109
+ "shards" ,
110
+ "tags" ,
111
+ "version" ,
112
+ }
113
+
114
+ const settingsColl = "settings"
115
+
116
+ var settingsToSkip = []string {
117
+ "balancer" ,
118
+ "automerge" ,
119
+ }
120
+
103
121
var ErrNoCloningNamespace = errors .New ("cloning namespace desn't exist" )
104
122
105
123
// cloneNS has all data related to cloning namespace within oplog
@@ -322,10 +340,14 @@ func isOpAllowed(oe *Record) bool {
322
340
return true // OK: not a "config" database. allow any ops
323
341
}
324
342
325
- if slices .Contains (dumprestore . ConfigCollectionsToKeep , coll ) {
343
+ if slices .Contains (configCollToKeep , coll ) {
326
344
return true // OK: create/update/delete a doc
327
345
}
328
346
347
+ if coll == settingsColl {
348
+ return isConfigSettingAllowed (oe )
349
+ }
350
+
329
351
if coll != "$cmd" || len (oe .Object ) == 0 {
330
352
return false // other collection is not allowed
331
353
}
@@ -342,6 +364,20 @@ func isOpAllowed(oe *Record) bool {
342
364
return false
343
365
}
344
366
367
+ // isConfigSettingAllowed filter out entries from config.settings collection
368
+ func isConfigSettingAllowed (oe * Record ) bool {
369
+ for _ , e := range oe .Query {
370
+ if e .Key != "_id" {
371
+ continue
372
+ }
373
+ setting , _ := e .Value .(string )
374
+ if slices .Contains (settingsToSkip , setting ) {
375
+ return false
376
+ }
377
+ }
378
+ return true // allow setting from config.settings
379
+ }
380
+
345
381
func (o * OplogRestore ) isOpSelected (oe * Record ) bool {
346
382
if o .includeNS == nil || o .includeNS ["" ] != nil {
347
383
return true
@@ -412,6 +448,8 @@ func (o *OplogRestore) isOpForCloning(oe *db.Oplog) bool {
412
448
return false
413
449
}
414
450
451
+ // isOpExcluded check if collection is excluded.
452
+ // Mostly refers PBM's control collections, but also some config and admin ones.
415
453
func (o * OplogRestore ) isOpExcluded (oe * Record ) bool {
416
454
if o .excludeNS == nil {
417
455
return false
0 commit comments