Newbie Question - Best practice to copy a collection and its indexes between Dbs

772 views
Skip to first unread message

D Boyd

unread,
Dec 28, 2010, 5:45:56 PM12/28/10
to mongodb-user
All:
Somewhat newbie question. I have some basically static data that
has had a lot of massaging and cleanup
done to it in a development database.

Now I want to copy that collection and all its indexes to my
production db on the same host.

Import/Export will do the data.
Dump/Restore will do both but to do it for a single collection
required dumping the whole source db to get the system.indexes which
seems like overkill.
The clonecollection database command says specifically not to run on
the same instance.

I am thinking I am going to need to write a console javascript or java
program to do this easily.

Any thoughts from the list.

Or am I missing something obvious?

roger

unread,
Dec 28, 2010, 7:50:07 PM12/28/10
to mongodb-user
You could write a small program, or do dump/restore and then manually
add the indexes. Clone collection should be able to handle this, feel
free to file a Jira...

-Roger

Eliot Horowitz

unread,
Dec 28, 2010, 11:12:45 PM12/28/10
to mongod...@googlegroups.com
Do you want to copy the whole db, or just an individual collection?
For a whole db, dump/restore does the data and indexes.
For a single collection, it doesn't do indexes, but easy to do yourself.
There is a case to add indexes: http://jira.mongodb.org/browse/SERVER-1311

> --
> 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.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages