Skip to content

Instantly share code, notes, and snippets.

@JaniAnttonen
Last active March 18, 2024 09:58
Show Gist options
  • Save JaniAnttonen/90945058ed41616f96d2cfa5f131bd09 to your computer and use it in GitHub Desktop.
Save JaniAnttonen/90945058ed41616f96d2cfa5f131bd09 to your computer and use it in GitHub Desktop.

Revisions

  1. JaniAnttonen revised this gist May 23, 2017. No changes.
  2. JaniAnttonen created this gist May 23, 2017.
    20 changes: 20 additions & 0 deletions mongoDump.md
    Original 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.