Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-317

Copy a single collection from DB1 to DB2

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.1.2
    • Affects Version/s: 1.0.0
    • Component/s: Tools
    • None
    • Environment:
      Mac OS X

      With the current mongodump/mongorestore, it's not possible to copy just one collection from one database to another
      (see this thread on mongodb-user: http://groups.google.com/group/mongodb-user/browse_thread/thread/daebd48eca33d3ee)

      I expected to do something like this, but unfortunately mongorestore does

      a) always use the original DB although I specified the target DB with the -d option (I heard the nightly builds behave different) and
      b) always restores the complete DB instead of a single collection.

      I thought I could copy over one collection to another DB with something like this:

      pinocchio:~ oliver$ mongodump -d services -c suppliers -o tmp/dump
      connected to: 127.0.0.1
      DATABASE: services to tmp/dump/services
      services.suppliers to tmp/dump/services/suppliers.bson
      29603 objects

      pinocchio:~ oliver$ mongorestore -d services_dev -c suppliers --dir
      tmp/dump/
      connected to: 127.0.0.1
      tmp/dump/services/suppliers.bson
      going into namespace [services.suppliers]
      read 489874/11917784 bytes so far. (4%) 1028 objects
      ...
      read 11605076/11917784 bytes so far. (97%) 28784 objects
      29603 objects

            Assignee:
            mike Michael Dirolf
            Reporter:
            oliver Oliver Eilhard
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: