How it works...
We begin simply by adding another collection to the existing mydb database, just to increase the sample dataset for verbosity. In step 2, we take a database backup by executing the mongodump utility with no special parameters other than the output directory.
In step 3, we use two new parameters-- --nsFrom and --nsTo. The value of the --nsFrom parameter indicates the namespace from which the restoration is supposed to be renamed, and the value of --nsTo indicates the target namespace. In our example, we are restoring the backup of data from mydb.mockdata to a new database newdb.mockdata. You may have noticed that I am still using the --nsInclude flag with the mydb.mockdata value. This ensures that the mongorestore utility is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access