Created
January 23, 2013 13:27
-
-
Save mindscratch/4605574 to your computer and use it in GitHub Desktop.
mongo replicaset rollback data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://docs.mongodb.org/manual/reference/bsondump/ | |
| fh = File.open("somefile.bson", "rb") | |
| while not fh.eof? do | |
| obj = BSON.read_bson_document fh | |
| id = obj.delete "_id" | |
| # assume Thing is a Mongoid::Document | |
| thing = Thing.new obj | |
| thing["_id"] = id.to_s | |
| thing.save | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment