1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-04 09:55:24 +02:00
tldr/pages/common/mongodump.md

33 lines
1 KiB
Markdown
Raw Normal View History

2016-08-26 16:31:49 +05:30
# mongodump
> Utility to export the contents of a MongoDB instance.
> More information: <https://docs.mongodb.com/database-tools/mongodump/>.
2016-08-26 16:31:49 +05:30
- Create a dump of all databases (this will place the files inside a directory called "dump"):
2016-08-26 16:31:49 +05:30
`mongodump`
- Specify an output location for the dump:
`mongodump {{[-o|--out]}} {{path/to/directory}}`
2016-08-26 16:31:49 +05:30
- Create a dump of a given database:
`mongodump {{[-d|--db]}} {{database_name}}`
2016-08-26 16:31:49 +05:30
- Create a dump of a given collection within a given database:
`mongodump {{[-c|--collection]}} {{collection_name}} {{[-d|--db]}} {{database_name}}`
2016-08-26 16:31:49 +05:30
- Connect to a given host running on a given port, and create a dump:
`mongodump {{[-h|--host]}} {{host}} --port {{port}}`
2016-08-26 16:31:49 +05:30
- Create a dump of a given database with a given username; user will be prompted for password:
`mongodump {{[-u|--username]}} {{username}} {{database}} {{[-p|--password]}}`
2021-10-22 20:29:04 +05:30
- Create a dump from a specific instance; host, user, password and database will be defined in the connection string:
`mongodump --uri {{connection_string}}`