Skip to content

Commit 0b0e883

Browse files
committed
don't run oplog reply if any of the namespace options are set
1 parent 949dc67 commit 0b0e883

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

internal/commands/database_restore.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,17 @@ func (command DatabaseRestoreCommand) Run() error {
105105
log.Info().Msgf("Successfully restored %d, Failed to restore %d", result.Successes, result.Failures)
106106

107107
if command.Mongo.InputOptions.OplogReplay {
108-
log.Info().Msg("Restoring Oplog")
108+
if command.Mongo.NamespaceOptions.Database == "" && command.Mongo.NamespaceOptions.Collection == "" &&
109+
len(command.Mongo.NamespaceOptions.NSExclude) == 0 && len(command.Mongo.NamespaceOptions.NSInclude) == 0 {
109110

110-
if err := command.RestoreOplog(ctx, s3Service, command.Key); err != nil {
111-
log.Err(err).Msg("Failed to restore oplog")
112-
return err
111+
log.Info().Msg("Restoring Oplog")
112+
113+
if err := command.RestoreOplog(ctx, s3Service, command.Key); err != nil {
114+
log.Err(err).Msg("Failed to restore oplog")
115+
return err
116+
}
117+
} else {
118+
log.Info().Msg("Skipping Oplog restore as database or collection is provided")
113119
}
114120
}
115121

0 commit comments

Comments
 (0)