Hi, first time posting here. I searched for my issue but only found results from over a year ago. I have a digital ocean mongo server, I am connected to it and from shell trying to export.
This all seems pretty straightforward and feel I must be missing something very generic/obvious.
I am running MongoDB 4.0.3 on Ubuntu 18.04, and mongoexport returns same version r4.0.3
Welcome to the MongoDB Community Forums @Richie_Madden !
Your usage looks fine so I expect there is an issue with the namespace parameters or the target deployment.
A database contains one or more collections. I’m wondering if perhaps you have a resolutions collection in a test database, which would mean your --collection and --db parameter values need to be swapped.
f you want to double-check the database and collection names in the mongo shell, the following count should match the count of documents exported by your original mongoexport command line:
That is expected behaviour: if a namespace is empty or doesn’t exist, there will 0 documents exported.
Are you running mongoexport in the same Digital Ocean instance as your MongoDB deployment or using port forwarding? If not, localhost may not be connecting to the intended deployment.
Stupid user error. Yep, had db and collection reversed. I have been working with RDBMS systems for decades and I am still new to document databases, MongoDB. I have still not fully translated collection to table, IMO. With that, with collection being a new word in my head, I mixed them up.
Humbling! Needed this I guess to never do it again.
Immediately my local export on Windows 10 using Putty for tunnel for connection worked and exported all records as needed.
Glad that worked out! No need to apologise for being a learner – we all have to pass through that stage
If you prefer GUI to command line, you may be interested in MongoDB Compass which includes a more visual way to confirm you are exporting the expected data: Export Data from a Collection.