Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
Mongoose Export and Import MongoDB Documents to/from File

Using JavaScript and Mongoose, I want to export all of the documents of a certain document class to a file (e.g., a JSON or CSV file), and I also want to import (i.e., "load") the contents of such a file into a database. How can I accomplish this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

From mongoDB docs:

EXPORT / BACKUP

To backup data from a mongod instance running on the same machine and on the default port of 27017, use the following command:

mongodump

You can also specify the --host and --port of the MongoDB instance that the mongodump should connect to. For example:

mongodump --host=mongodb.example.net --port=27017

mongodump will write BSON files that hold a copy of data accessible via the mongod listening on port 27017 of the mongodb.example.net host. See Create Backups from Non-Local mongod Instances for more information.

To specify a different output directory, you can use the --out or -o option:

mongodump --out=/data/backup/

IMPORT / RESTORE

To use mongorestore to connect to an active mongod, use a command with the following prototype form:

mongorestore --port=<port number> <path to the backup>

Consider the following example:

mongorestore dump-2013-10-25/

MongoDB Docs: Check

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!