Issue
I have a MongoDB database running on a headless Raspberry Pi 3 which runs 32-bit Raspbian and MongoDB v2.4. I also have MongoDB running on my Mac, with 64-bit Big Sur and MongoDB v5.0.
I have data that I'd like to move from my Pi to my Mac. How could I accomplish this? Would it even be compatible?
In MongoDB v2, there's db.copyDatabase() which has since been deprecated since v4. In MongoDB v4, there's mongodump
, but that's incompatible with v2.
Solution
in your raspberrypi dupm your db with:
mongodump --db=dbname --out=./
and send it to mac and on your mac restore it by :
mongorestore -d dbname -c collectionName /place_of_dumpfile --drop
do it for each collection , or
mongorestore -d dbname /place_of_dumpfile --drop
Answered By - mohammad Naimi