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.
Revisions
-
fahimbabarpatel revised this gist
Sep 30, 2015 . 1 changed file with 12 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,44 +1,47 @@ NOTE - * Remove **-h** option if you are doing operation on same machine * Remove **-u** , **-p** option if your database don't have username and password ### Binary **Import database** ``` mongorestore -h IP:port -d DB_Name -u user_name -p password <input db directory> ``` **Export database** ``` mongodump -h IP:port -d DB_Name -u user_name -p password -o <output directory> ``` **Import collection** ``` mongorestore -h IP:port -d DB_Name -u user_name -p password <input .bson file> ``` **Export collection** ``` mongodump -h IP:port -d DB_Name -c collection_name -u user_name -p password -o <output directory> ``` ### JSON **Import collection** ``` mongoimport -h IP:port -d DB_Name -c collection_name -u user_name -p password --file <input file> ``` **Export collection** ``` mongoexport -h IP:port -d DB_Name -c collection_name -u user_name -p password -o <output file> ``` ### CSV **Import collection** ``` mongoimport -h IP:port -d DB_Name -c collection_name -u user_name -p password --file <input .csv file> --type csv --headerline ``` **Export collection** ``` mongoexport -h IP:port -d DB_Name -c collection_name -u user_name -p password -o <output .csv file> --csv -f <comma-separated list of field names> ``` -
fahimbabarpatel revised this gist
Sep 30, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ NOTE - Remove **-h** option if you are doing operation on same machine ### Binary -
fahimbabarpatel revised this gist
Sep 30, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ *NOTE - Remove **-h** option if you are doing operation on same machine* ### Binary **Import database** -
fahimbabarpatel revised this gist
Sep 30, 2015 . 1 changed file with 21 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ### Binary **Import database** ``` @@ -8,23 +8,35 @@ mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input db directory> ``` mongodump -h IP:port -d DB_Name -u <user> -p <password> -o <output directory> ``` **Import collection** ``` mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input .bson file> ``` **Export collection** ``` mongodump -h IP:port -d DB_Name -c <collection> -u <user> -p <password> -o <output directory> ``` ### JSON **Import collection** ``` mongoimport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> --file <input file> ``` **Export collection** ``` mongoexport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> -o <output file> ``` ### CSV **Import collection** ``` mongoimport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> --file <input .csv file> --type csv --headerline ``` **Export collection** ``` mongoexport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> -o <output .csv file> --csv -f <comma-separated list of field names> ``` -
fahimbabarpatel revised this gist
Sep 30, 2015 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,13 @@ #### Binary **Import database** ``` mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input db directory> ``` **Export database** ``` mongodump -h IP:port -d DB_Name -u <user> -p <password> -o <output directory> ``` #### Import collection mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input .bson file> #### Export collection -
fahimbabarpatel revised this gist
Sep 30, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ #### Binary **Import database** mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input db directory> **Export database** mongodump -h IP:port -d DB_Name -u <user> -p <password> -o <output directory> #### Import collection mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input .bson file> -
fahimbabarpatel revised this gist
Sep 30, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ #### Binary * Import database mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input db directory> * Export database mongodump -h IP:port -d DB_Name -u <user> -p <password> -o <output directory> #### Import collection mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input .bson file> -
fahimbabarpatel revised this gist
Sep 30, 2015 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,26 @@ *Binary* #### Import database mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input db directory> #### database mongodump -h IP:port -d DB_Name -u <user> -p <password> -o <output directory> #### Import collection mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input .bson file> #### Export collection mongodump -h IP:port -d DB_Name -c <collection> -u <user> -p <password> -o <output directory> *JSON* #### Import collection mongoimport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> --file <input file> #### Export collection mongoexport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> -o <output file> *CSV* #### Import collection mongoimport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> --file <input .csv file> --type csv --headerline #### Export collection mongoexport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> -o <output .csv file> --csv -f <comma-separated list of field names> -
fahimbabarpatel revised this gist
Sep 30, 2015 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,26 @@ *Binary* Import database mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input db directory> Export database mongodump -h IP:port -d DB_Name -u <user> -p <password> -o <output directory> Import collection mongorestore -h IP:port -d DB_Name -u <user> -p <password> <input .bson file> Export collection mongodump -h IP:port -d DB_Name -c <collection> -u <user> -p <password> -o <output directory> *JSON* Import collection mongoimport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> --file <input file> Export collection mongoexport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> -o <output file> *CSV* Import collection mongoimport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> --file <input .csv file> --type csv --headerline Export collection mongoexport -h IP:port -d DB_Name -c <collection> -u <user> -p <password> -o <output .csv file> --csv -f <comma-separated list of field names> -
fahimbabarpatel renamed this gist
Sep 30, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
fahimbabarpatel created this gist
Sep 30, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ *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>