Horje
mongodb clone database Code Example
clone mongodb database to local machine
# Dump remote database to a local folder
mongodump --uri "mongodb+srv://username:password@host/mydb" --out ./myfolder

# Restore the database from the folder to localhost
mongorestore --port 27017 ./myfolder

# (Restore back to the remote)
mongorestore --host=example.com --port=27017 -u username -p password --db mydb ./myFolder
mongodb clone database
# Dump db to a local folder
mongodump mongodb://user:pwd@localhost/old_name -o ./dump 

# Restore the db with the new name
mongorestore mongodb://user:pwd@localhost -d new_name ./dump/old_name

# Try this flag if you get an authentication error
--authenticationDatabase admin
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.*'




Shell

Related
convert ppk to pem Code Example convert ppk to pem Code Example
curl download file without output Code Example curl download file without output Code Example
git check merged branches Code Example git check merged branches Code Example
tensorflow docker hub Code Example tensorflow docker hub Code Example
git force pull from upstream discard changes Code Example git force pull from upstream discard changes Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10