Forked from fahimbabarpatel/Mongodb restore and dump commands via json, bson and csv.md
Created
August 14, 2019 01:40
-
-
Save anhnt/64380ecd69efd129b9d239fd54523c16 to your computer and use it in GitHub Desktop.
Mongodb restore and dump commands via json, bson and csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *Binary* | |
| Import database | |
| mongorestore -h ds041871.mongolab.com:41871 -d azdms -u <user> -p <password> <input db directory> | |
| Export database | |
| mongodump -h ds041871.mongolab.com:41871 -d azdms -u <user> -p <password> -o <output directory> | |
| Import collection | |
| mongorestore -h ds041871.mongolab.com:41871 -d azdms -u <user> -p <password> <input .bson file> | |
| Export collection | |
| mongodump -h ds041871.mongolab.com:41871 -d azdms -c <collection> -u <user> -p <password> -o <output directory> | |
| *JSON* | |
| Import collection | |
| mongoimport -h ds041871.mongolab.com:41871 -d azdms -c <collection> -u <user> -p <password> --file <input file> | |
| Export collection | |
| mongoexport -h ds041871.mongolab.com:41871 -d azdms -c <collection> -u <user> -p <password> -o <output file> | |
| *CSV* | |
| Import collection | |
| mongoimport -h ds041871.mongolab.com:41871 -d azdms -c <collection> -u <user> -p <password> --file <input .csv file> --type csv --headerline | |
| Export collection | |
| mongoexport -h ds041871.mongolab.com:41871 -d azdms -c <collection> -u <user> -p <password> -o <output .csv file> --csv -f <comma-separated list of field names> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment