Mongorestore to a different database

You need to actually point at the “database name” container directory “within” the output directory from the previous dump:

mongorestore -d db2 dumpdir/db1

And usually just <path> is fine as a positional argument rather than with -dir which would only be needed when “out of position” i.e “in the middle of the arguments list”.

p.s. For archive backup file (tested with mongorestore v3.4.10)

mongorestore --gzip --archive=${BACKUP_FILE_GZ} --nsFrom "${DB_NAME}.*" --nsTo "${DB_NAME_RESTORE}.*"

Leave a Comment