Reputation: 12804
I'm having some trouble at restoring a dump and replaying the oplog on MongoDB.
I have to replay the oplog up to a certain point of time, thus issuing the following command:
mongorestore --port <n> --db <name> --oplogReplay --oplogLimit <ts> <dumpfile>
But mongorestore replies "Can only replay oplog on full restore".
Looking at the source code it seems like this error message is displayed when the user doesn't specify the --db option, but I did.
Do you know what else could be the cause?
Upvotes: 2
Views: 2520
Reputation: 27487
I believe it's the opposite issue - you cannot specify a database when using the oplog option. The code you found:
if (mongoRestoreGlobalParams.oplogReplay) {
// fail early if errors
if (toolGlobalParams.db != "") {
toolError() << "Can only replay oplog on full restore" << std::endl;
return -1;
}
triggers when you both specify oplogReplay AND a database.
Keep in mind the oplog is for the entire mongodb instance, not a specific database. I believe taking a mongodump using --oplog is going to dump the entire instance and therefore it cannot be re-loaded into just one database.
It's fairly poorly documented. Mongolab alludes to it in their documentation:
Point-in-time method
Applicable to Dedicated plans only
If you have a Dedicated plan, you can take server-wide mongodumps to export all of the databases on the server.
This method is useful because it allows you to use the the --oplog and --oplogReplay options to mongodump and mongorestore (respectively). The options allow for a point-in-time snapshot of the server by also including the oplog in the dump. This oplog is then replayed when you use the --oplogReplay option upon restore.
but it's not very clear.
Upvotes: 2