Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

mongo copy database

Before MongoDB version 4.2
source_db.copyDatabase('destination_db')

After MongoDB version 4.2
mongodump --archive="mongodump-source-db" --db=source_db
mongorestore --archive="mongodump-source-db" --nsFrom='source_db.*' --nsTo='destination_db.*'

Or,

mongodump --archive --db=source_db | mongorestore --archive  --nsFrom='source_db.*' --nsTo='destination_db.*'
Source by docs.mongodb.com #
 
PREVIOUS NEXT
Tagged: #mongo #copy #database
ADD COMMENT
Topic
Name
9+7 =