@@ -187,7 +187,7 @@ func (r *Restore) Snapshot(
187
187
return errors .Wrap (err , "set backup name" )
188
188
}
189
189
190
- err = r .checkSnapshot (ctx , bcp )
190
+ err = r .checkSnapshot (ctx , bcp , nss )
191
191
if err != nil {
192
192
return err
193
193
}
@@ -316,7 +316,7 @@ func (r *Restore) PITR(
316
316
return errors .Wrap (err , "set backup name" )
317
317
}
318
318
319
- err = r .checkSnapshot (ctx , bcp )
319
+ err = r .checkSnapshot (ctx , bcp , nss )
320
320
if err != nil {
321
321
return err
322
322
}
@@ -697,7 +697,7 @@ func (r *Restore) snapshotObjects(bcp *backup.BackupMeta) (string, []oplog.Oplog
697
697
return rsMeta .DumpName , chunks , nil
698
698
}
699
699
700
- func (r * Restore ) checkSnapshot (ctx context.Context , bcp * backup.BackupMeta ) error {
700
+ func (r * Restore ) checkSnapshot (ctx context.Context , bcp * backup.BackupMeta , nss [] string ) error {
701
701
if bcp .Status != defs .StatusDone {
702
702
return errors .Errorf ("backup wasn't successful: status: %s, error: %s" ,
703
703
bcp .Status , bcp .Error ())
@@ -731,6 +731,16 @@ func (r *Restore) checkSnapshot(ctx context.Context, bcp *backup.BackupMeta) err
731
731
bcp .MongoVersion , ver .VersionString )
732
732
return nil
733
733
}
734
+
735
+ if r .brief .Sharded && ver .IsConfigShardSupported () && util .IsSelective (nss ) {
736
+ hasConfigShard , err := topo .HasConfigShard (ctx , r .leadConn )
737
+ if err != nil {
738
+ return errors .Wrap (err , "check for Config Shard" )
739
+ }
740
+ if hasConfigShard {
741
+ return errors .New ("selective restore is not supported with Config Shard" )
742
+ }
743
+ }
734
744
}
735
745
736
746
return nil
0 commit comments