0

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)
                }
        }
}
Deepa B
  • 1
  • 1
  • 4

1 Answers1

0

An alternative would probably be to use mongoDump/mongorestore.

https://stackoverflow.com/a/22201759/5107937

Jack Vabre
  • 37
  • 1
  • 8
  • I cannot do this as my mongodb in dev is part of meteor. I cannot install mongo seperately. is there any other way? – Deepa B Dec 18 '18 at 13:56
  • ? I'm not sure to understand but... if it's a default configuration like i guess. you just need your application to run then type the command: mongodump -h 127.0.0.1 --port 3001 -d meteor, as described on the link i wrote. It will create a dump folder in your application. – Jack Vabre Dec 20 '18 at 06:27