HiveBrain v1.2.0
Get Started
← Back to all entries
patternCritical

How restore a specific database from backup using mongorestore command

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
howmongorestoredatabaseusingspecificcommandfromrestorebackup

Problem

I created a backup of all my databases using mongodump command. Now I want to restore a specific database using mongorestore command.

How is this possible, I use this command: --db option then mongodb doesn't restore a specific database.

Solution

To restore a single database you need to provide the path to the dump directory as part of the mongorestore command line.

For example:

# Backup the training database
mongodump --db training

# Restore the training database to a new database called training2
mongorestore --db training2 dump/training


The --db option for mongodump specifies the source database to dump.

The --db option for mongorestore specifies the target database to restore into.

Code Snippets

# Backup the training database
mongodump --db training

# Restore the training database to a new database called training2
mongorestore --db training2 dump/training

Context

StackExchange Database Administrators Q#113017, answer score: 103

Revisions (0)

No revisions yet.