Good day to all!
Not so long ago, I rebuilt the world in gentoo, which resulted in an update mongoDB. Launched the console, completed the usual
mongodump
and
mongorestore
. I open my application and see a bunch of errors that some of the collections do not exist. I restarted
mongodump
,
mongorestore
, I check the list of collections and I see that out of 50 collections only ~ 30 exist.
He began to understand and came to the conclusion that the problem was hidden in the following: mongodb2.4 is installed on the server, and I have mongodb2.6 installed.
My first thought was to quickly
rebuild Mongu with version 2.4 and enjoy life. This, as they say, is not kosher. I turned to Google for help, but I managed to find out only that in mongo2.6 the logic of the work of the collection creation team was changed. Now you cannot use "size = null" and "max = null". But a solution to this problem was not provided.
And today, thanks to Habrauzer’s
Kuzma hint, 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 yet exist, issue 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 creating
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 remote-db-name database and create a copy of it locally with the name of how-it-will-be-called-locally
That's all.