I tried a mongo export like this:
./mongodump --db local --collection lecturer
and then I tried:
./mongodump --db local --collection posts --out - > lecturer .csv
and I get the same error message: Syntax Error: syntax error (shell):1
By default, mongorestore looks for a database backup in mongodb's bin\dump folder which is also the default folder for mongodump command for dumping the backup. Example: In this example, we are using a database GeeksForGeeks which has 4 collections.
Choose a file type and export location.Under Select Export File Type, select either JSON or CSV. If you select JSON, your data is exported to the target file as a comma-separated array. Then, under Output, choose where to export the file to.
Start Mongo, open a new tab in terminal. First navigate to the folder where you want to save the backup, then type the following command.
Backup single database:
mongodump --host localhost --port 27017 --db db_name
Restore single database:
mongorestore --host localhost --port 27017 --db **** dump/db_name
(In this case, ****
represents UserDefinedName for the database > mydb dump/db_name > this will import dump db into mydb)
Backup all databases:
mongodump --host localhost --port 27017
Restore all databases:
mongorestore --host localhost --port 27017 dump
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With