Jyotman Singh
Jyotman Singh

Reputation: 11330

MongoDB restore warning

I'm following this tutorial to backup and restore a single MongoDB database.

The backup command -

sudo mongodump --db newdb --out /var/backups/mongobackups/`date +"%m-%d-%y"`

The restore command -

sudo mongorestore --db newdb --drop /var/backups/mongobackups/01-20-16/newdb/

Although it works perfectly, MongoDB gives me this warning while restoring the data -

the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead

Can someone explain how to remove this warning?

I'm using MongoDB 3.4.1 version.

Upvotes: 25

Views: 33653

Answers (4)

Bipul Chandra Dev Nath
Bipul Chandra Dev Nath

Reputation: 431

I was having the same problem, and finally I noticed that I had missed the actual backup folder URL. My backup database folder is in a subfolder.

I was trying for

sudo mongorestore -d database 'Database-13-03-23'

But it should be

sudo mongorestore -d database 'Database-13-03-23/13-03-23/database'

Upvotes: 1

Reyhaneh Torab
Reyhaneh Torab

Reputation: 367

You could remove --db and the error will goes away:

mongorestore  newdb  --drop /var/backups/mongobackups/01-20-16/

In my case, I didn't need any flag to set the db name.

Upvotes: 0

jiucai
jiucai

Reputation: 21

just execute command like this:

sudo mongorestore /var/backups/mongobackups/01-20-16

Upvotes: -12

acsrujan
acsrujan

Reputation: 1049

--nsInclude is new in mongo 3.4.

Instead of older options where db_name and collection_name are given in command line as

mongorestore --db db_name --collection collection_name

namespaces are to be used

mongorestore --nsInclude db_name.collection_name

Similarly

mongorestore --db newdb --drop /var/backups/mongobackups/01-20-16/newdb/

becomes

mongorestore --nsInclude 'newdb.*' --drop /var/backups/mongobackups/01-20-16/

Upvotes: 34

Related Questions