Problem with mongorestore between mongodb2.4 and mongodb2.6
Good day to all!
Recently rebuilt the world in gentoo, which led to the mongoDB update. I launched the console, performed the usual
mongodump
and mongorestore
. I open my application and see a bunch of errors that some of the collections do not exist. Restarted mongodump
, mongorestore
, check the list of collections and see that out of the 50 collections, there is only ~ 30. I started to understand and came to the conclusion that the problem was as follows: mongodb2.4 is installed on the server, and mongodb2.6 is installed on me.
And today, thanks to the prompt of Habrauser kuzma, a solution was found. Everything turned out and earned. Therefore, I decided to share it with everyone, maybe it will be useful to someone else.
If the how-it-will-be-called-locally database (see below) does not exist yet, run the following command:
mongo --eval "db.copyDatabase('remote-db-name','how-it-will-be-called-locally','server-address','user','password')"
If the database already exists, it must be deleted before creation.
mongo how-it-will-be-called-locally --eval "db.dropDatabase(); db.copyDatabase('remote-db-name','how-it-will-be-called-locally', 'server-address','user','password')"
The above code will copy the remote database remote-db-name and create a copy of it locally with the name how-it-will-be-called-locally.
That's all.