How to clone/copy a database in Azure Cosmos DB

旧巷老猫 提交于 2019-12-11 14:42:18

问题


How do I clone a database in Azure Cosmos DB to a mongod running on localhost:27001?

I've tried the following, but I can't get it working:

db.cloneDatabase("mycosmosdb:mypassword@username.documents.azure.com:10255/MyDatabase?ssl=true&replicaSet=globaldb")

This returns the following when running the command from my local machine where mongod is running :

{
    "clonedColls" : [ ],
    "ok" : 0,
    "errmsg" : "connect failed to replica set mycosmosdb:mypassword@username.documents.azure.com:10255/Mydatabase?ssl=true&replicaSet=globaldb:27017",
    "code" : 6,
    "codeName" : "HostUnreachable"
}

Trying this variant also fails:

db.copyDatabase("NameOfAzureDB", "NameOfLocalDB", "username.documents.azure.com:10255", "username", "password")

{
    "ok" : 0,
    "errmsg" : "couldn't connect to server username.documents.azure.com:27017, connection attempt failed"
}

回答1:


cloneDatabase is not supported on Cosmos DB as clone command that it wraps around is not flexible enough to allow SSL connection and the name of the replica set. It only accepts the hostname and port number and nothing else, so the connection string used in the question is not supported (and there's no such moniker as "mycosmosdb" either).




回答2:


With the new Cosmic Clone tool, you can

  1. To clone collections for any environments
  2. Create collections with similar settings(indexes, partition, TTL etc)
  3. Anonymize data through scrubbing or shuffling of sensitive data in documents.

Read my blog on the same.



来源:https://stackoverflow.com/questions/49155167/how-to-clone-copy-a-database-in-azure-cosmos-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!