LinuxCommandLibrary

mongorestore

restores MongoDB data from mongodump output

TLDR

Restore from dump directory
$ mongorestore [dump/]
copy
Restore specific database
$ mongorestore --db=[database] [dump/database/]
copy
Restore to remote host
$ mongorestore --host=[hostname] --port=[27017] [dump/]
copy
Restore with drop
$ mongorestore --drop [dump/]
copy
Restore from archive
$ mongorestore --archive=[backup.archive]
copy

SYNOPSIS

mongorestore [options] [directory]

DESCRIPTION

mongorestore restores MongoDB data from mongodump output. Part of MongoDB Database Tools. Restores BSON files to MongoDB collections. Supports full and selective restoration.

PARAMETERS

--db name

Target database name.
--collection name
Target collection.
--drop
Drop collections before restore.
--host host
MongoDB host.
--archive file
Restore from archive file.
--gzip
Decompress gzipped input.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard