0
votes

I'm moving a website and Mongo database to a new server.
Website can't see the data.
Mongo is installed and running on the same server.
Shell and server are both 3.6.3

Mongo shell sees the database.
From the shell,

dbs returns the database name.
use dbname appears to work.
db.getCollectionNames() returns a reasonable collection name. Say ["myCollection"]

.

db.getCollection("myColection").getIndexes() returns
[ { "v" : 2, "key" : { "_id" : 1 }, "name" : "id", "ns" : "myDB.myCollection" } ]

But after that, I can't get any further.

db.myCollection.find() and
db.getCollection("myCollection").find() both return nothing.

Everything in the log looks correct, no errors.

Does that tell us anything?

2
What are the results of version() and db.version() in your mongo shell? One possibility is that you are using a shell version that is much older than your MongoDB server version. - Stennie
@Stennie Great question. Should have included the version. - BWhite
@Stennie I think you are onto something. The data was probably built with an old storage engine. WiredTiger is newer than the old install. So it wouldn't have used WiredTiger. - BWhite
If your mongo shell version matches the server version (and both are 3.6.3), that should remove the possibility that the issue is with an older shell which hasn't been updated for the MongoDB 3.0+ storage engine API (which would exhibit similarly). Have you definitely restored your data into the correct database on your new server? Does db.myCollection.stats() have the expected count and size of documents? - Stennie
@Stennie Stats looked empty. Thanks for the tip. - BWhite

2 Answers

0
votes

Use below to backup

Mongodump --out <directory>

and below to restore

mongorestore <collectionName><path to the backup>

0
votes

One of the features of Mongo is that you can create a database or collection just by mentioning it.
Turns out that someone had tried to import the data and failed. So when I looked at 'show dbs' and 'getCollectionNames', it looked like it was working.
The files I saw in the database directory were export files that hadn't actually been imported.