I am trying to copy a database [mongodb] in production server hosted in nginx to my local dev environment setup [linux machine].
I tried the solution given in following url How do I copy a database from one MongoDB server to another?
But when I establish a ssh tunnel and try to copy, I am getting following error
db.copyDatabase("admin","testadmin","localhost:27018")
{
"ok" : 0,
"errmsg" : "couldn't connect to server localhost:27018, connection attempt failed"
}
if I try to copy the database directly in my destination server. I am getting the following error
db.copyDatabase("admin","testadmin","mongodb://<remotehostname>:27017")
{
"operationTime" : Timestamp(1545126863, 1),
"ok" : 0,
"errmsg" : "Must specify set name for replica set ConnectionStrings",
"code" : 9,
"codeName" : "FailedToParse",
"$clusterTime" : {
"clusterTime" : Timestamp(1545126863, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}
Please help. I am stuck with issue for two days. I am not sure whether I can use mongodump and restore. I am using mongo version 3.4 in my remote server and mongo version 3.6 in my local. Could this be a problem?
I also tried adding replica set, but got below error. How to find the replica set name?
db.copyDatabase("admin","testadmin","mongodb://<remotehostname>:27017/?replicaSet=test")
{
"operationTime" : Timestamp(1545117923, 135),
"ok" : 0,
"errmsg" : "Bad digit \"/\" while parsing 27017/?replicaSet=test",
"code" : 9,
"codeName" : "FailedToParse",
"$clusterTime" : {
"clusterTime" : Timestamp(1545117923, 135),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}