Skip to content

Instantly share code, notes, and snippets.

@mindscratch
Created January 23, 2013 13:27
Show Gist options
  • Select an option

  • Save mindscratch/4605574 to your computer and use it in GitHub Desktop.

Select an option

Save mindscratch/4605574 to your computer and use it in GitHub Desktop.
mongo replicaset rollback data
# 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