FAQ

[mongodb-user] Why does not the "db.cloneCollection()" work as it says?

Yang
Aug 5, 2012 at 3:00 pm
I try to use "db.cloneCollection()" command to copy a collection from one
database(remote) to another, but I can't see the collection in the
destination database. Why? Here is what I did:
On host A (IP : 192.168.1.11), I have a collection named "user_info" in the
database "test".
On Host B (IP: 192.168.1.22), I run the following command within the mongo
shell:
db.cloneCollection("192.168.1.11", "test.user_info")

The "user_info" collection is small, only tens of documents. The command
completed quickly with an output message: "{ "ok" : 1 }", but when I try to
check the results with the following command:
db.getCollectionNames()
there is no collection named "user_info" which I hoped to have copied from
the remote to local database.
Did I missed something?


--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user+unsubscribe@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
reply

Search Discussions

4 responses

  • Sergei Tulentsev at Aug 5, 2012 at 3:20 pm
    I think your syntax is wrong.
    This is what documentation says:
    http://www.mongodb.org/display/DOCS/cloneCollection+Command
    On Sun, Aug 5, 2012 at 7:00 PM, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the mongo
    shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied from
    the remote to local database.
    Did I missed something?


    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb


    --
    Best regards,
    Sergei Tulentsev

    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb
  • Sergei Tulentsev at Aug 5, 2012 at 3:21 pm
    Oh, never mind, I was looking at the wrong thing :)
    On Sun, Aug 5, 2012 at 7:19 PM, Sergei Tulentsev wrote:

    I think your syntax is wrong.
    This is what documentation says:
    http://www.mongodb.org/display/DOCS/cloneCollection+Command

    On Sun, Aug 5, 2012 at 7:00 PM, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the
    mongo shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied
    from the remote to local database.
    Did I missed something?


    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb


    --
    Best regards,
    Sergei Tulentsev


    --
    Best regards,
    Sergei Tulentsev

    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb
  • Yang at Aug 5, 2012 at 3:46 pm
    Do I have to use the same database name at the destination host, or I can
    choose to clone a collection to a database with different name?
    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the mongo
    shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied from
    the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the mongo
    shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied from
    the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the mongo
    shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied from
    the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the mongo
    shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied from
    the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the mongo
    shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied from
    the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the mongo
    shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied from
    the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the mongo
    shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied from
    the remote to local database.
    Did I missed something?

    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb
  • Andre.defrere at Aug 6, 2012 at 4:51 am
    Hi Yang,

    The problem appears to be "test.user_info" in your CloneCollection command.
    If you check your logs for the Mongo instance you are copying to you will
    probably find an entry that says it is trying to copy a collection
    "test.test.user_info".

    Try the following commands from Host B:

    use test
    db.cloneCollection("192.168.1.11", "user_info")

    And it should work.

    I'm not sure if this is a bug or the documentation not being very clear. I
    will raise a ticket on Jira.

    Cheers,
    André
    On Monday, August 6, 2012 1:46:24 AM UTC+10, Yang wrote:

    Do I have to use the same database name at the destination host, or I can
    choose to clone a collection to a database with different name?
    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the
    mongo shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied
    from the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the
    mongo shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied
    from the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the
    mongo shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied
    from the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the
    mongo shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied
    from the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the
    mongo shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied
    from the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the
    mongo shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied
    from the remote to local database.
    Did I missed something?



    On Sunday, August 5, 2012 11:00:42 PM UTC+8, Yang wrote:

    I try to use "db.cloneCollection()" command to copy a collection from one
    database(remote) to another, but I can't see the collection in the
    destination database. Why? Here is what I did:
    On host A (IP : 192.168.1.11), I have a collection named "user_info" in
    the database "test".
    On Host B (IP: 192.168.1.22), I run the following command within the
    mongo shell:
    db.cloneCollection("192.168.1.11", "test.user_info")

    The "user_info" collection is small, only tens of documents. The command
    completed quickly with an output message: "{ "ok" : 1 }", but when I try to
    check the results with the following command:
    db.getCollectionNames()
    there is no collection named "user_info" which I hoped to have copied
    from the remote to local database.
    Did I missed something?

    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb

Related Discussions

Discussion Navigation
viewthread | post