DATABASE » NOSQL » MONGODB

Backup

Usage

Options to connect to a database (like --port or --host) can be used in addition to the options bellow.

Dump

shell
mongodump OPTIONS
OptionDescription
-d --dbSpecifies a database to backup.
-c --collectionSpecifies a collection to backup.
-o --outSpecifies the directory to write BSON files for the dumped databases (default: current directory).

Restore

Looks for a folder called 'dump', and inside it the name of the databases to be restored.

shell
mongorestore OPTIONS
OptionDescription
-d --dbSpecifies a database to restore.
-c --collectionSpecifies a collection to restore.
--dirSpecifies the dump directory.

Export

shell
mongoexport OPTIONS
OptionDescription
-d --dbSpecifies a database to export.
-c --collectionSpecifies a collection to export.
-o --outSpecifies the directory to write JSON files for the dumped databases (default: standard output).