How to use -oplogReplay & --oplog

486 views
Skip to first unread message

MarkW

unread,
May 21, 2012, 6:56:57 PM5/21/12
to mongodb-user
I am not really sure how to use --oplog and --oplogReplay options.

I am having an issue where --oplogReplay does not apply any changes to
a remote instance.

Example

#1 download sample collection
wget http://media.mongodb.org/zips.json

#2 import collection
mongoimport -h localhost --db scratch --collection zips --file
zips.json

#3 count collection
db.zips.find().count()
29470

#4 Take a backup of localhost
mongodump -h localhost

#5 restore backup to another instance
mongorestore -h remotehost dump

#6 Count objects on remote host
db.zips.find().count()
29470

#7 Delete all objects from localhost where state = FL and count
objects
db.zips.remove({state:'FL'})
db.zips.find().count()
28644

#8 take a backup of localhost using --oplog
mongdump -h localhost --oplog

#9 restore backup to remote host with --oplogReplay
mongorestore -h remotehost --oplogReplay dump

#10 count objects on remote host
db.zips.find().count()
29470


As you can see the deletes that were applied to localhost never get
applied to remote host.

Is this right use of --oplog & oplogReplay?

Thanks,
-MarkW

Scott Hernandez

unread,
May 21, 2012, 7:23:20 PM5/21/12
to mongod...@googlegroups.com
The oplog option is to catch changes that happen during the dump.

Are you sure you removed the files from the first dump and didn't use
them for the second restore? And/or, did you delete the docs from the
remote server before restoring? By default the destination is not
dropped first -- see the --drop option.

http://www.mongodb.org/display/DOCS/Import+Export+Tools#ImportExportTools-mongorestore
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb

MarkW

unread,
May 23, 2012, 12:12:14 PM5/23/12
to mongodb-user
It works with --drop option on the restore.

But i was hoping it would only apply the updates without having to
drop the collection.


On May 21, 4:23 pm, Scott Hernandez <scotthernan...@gmail.com> wrote:
> The oplog option is to catch changes that happen during the dump.
>
> Are you sure you removed the files from the first dump and didn't use
> them for the second restore? And/or, did you delete the docs from the
> remote server before restoring? By default the destination is not
> dropped first -- see the --drop option.
>
> http://www.mongodb.org/display/DOCS/Import+Export+Tools#ImportExportT...
>
>
>
>
>
>
>
> On Mon, May 21, 2012 at 6:56 PM, MarkW <deviant.dolp...@gmail.com> wrote:
> > I am not really sure how to use --oplog and --oplogReplay options.
>
> > I am having an issue where --oplogReplay does not apply any changes to
> > a remote instance.
>
> > Example
>
> > #1 download sample collection
> >  wgethttp://media.mongodb.org/zips.json
Reply all
Reply to author
Forward
0 new messages