Home Ask Login Register

Developers Planet

Your answer is one click away!

Vipul February 2016

How to convert a MongoDb's capped collection to non-capped collection?

Due to some specific business requirement we were storing data into the MongoDB's capped collection but now complete requirement changed and we want ot preserve all records in that collection.

I am able to find "convertToCapped" command but didn't find any command to perform vise versa operation.

How can I convert it back to non-capped collection?


Alex Blex February 2016

You can copy it:

use admin
db.runCommand( { renameCollection: "yourdb.yourcollection", to: "yourdb.oldcapped" } )
use yourdb

Then ensure required indexes and create users in uncapped yourcollection. Run your tests, and if you are happy with results, drop oldcapped.

Needless to say it should be done within maintenance window.

Post Status

Asked in February 2016
Viewed 2,715 times
Voted 6
Answered 1 times


Leave an answer

Quote of the day: live life