Last active
March 18, 2024 09:58
-
-
Save JaniAnttonen/90945058ed41616f96d2cfa5f131bd09 to your computer and use it in GitHub Desktop.
Revisions
-
JaniAnttonen revised this gist
May 23, 2017 . No changes.There are no files selected for viewing
-
JaniAnttonen created this gist
May 23, 2017 .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,20 @@ First, find the container that runs your MongoDB and ssh into it. Then, find the collection you want to export: ```bash mongo show dbs use <database> show collections exit ``` Then, run mongoexport command in the shell (not in mongo): ```bash mongoexport -d <database-name> -c <collection-name> --out output.json ``` Then, on your local machine, copy the file from inside the docker container to your current folder: ```bash docker cp <mongodb docker container name>:/output.json . ``` Don't forget the dot from the end.