How restore from .gz backup with new database name using mongorestore r3.2.9?

Nothing works for me but this.

mongorestore --gzip --archive=/path/to/file.gz --db db_name

With 3.2.x you cannot use --nsFrom or --nsTo parameters. This pair of commands should work in all versions:

mongodump --db ${DB_NAME} --gzip -o ${BACKUP_FILE_GZ}

mongorestore --gzip --db "${DB_NAME_RESTORE}" ${BACKUP_FILE_GZ}/${DB_NAME}

Now you get a directory with gzipped files and you can restore all (or just one) collections to a different database.


That is because your mongodump script has an --archive flag.

Then you have to use it when doing mongorestore.