Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

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
Comment

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
Comment

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.*'
Comment

PREVIOUS NEXT
Code Example
Shell :: git reset remote 
Shell :: installing deb 
Shell :: kubernetes exec into pod 
Shell :: gcc for macos 
Shell :: install homebrew git mac 
Shell :: homebrew installation 
Shell :: bundle lock add platform linux 
Shell :: install Fdisk 
Shell :: bash rename foldr 
Shell :: watch and compile scss command 
Shell :: jest install 
Shell :: how to git clone from a specific branch git 
Shell :: copy files out of docker 
Shell :: Solve Cannot Install Dependency Error for NPM install 
Shell :: git look at changes to a file 
Shell :: yarn 2 upgrade all packages 
Shell :: ssh rsa pub to pem 
Shell :: dump database docker 
Shell :: shell script mac 
Shell :: composer install mac 
Shell :: install mysql in debian 
Shell :: run latex from command line 
Shell :: linux shuton after time 
Shell :: gcloud check region 
Shell :: kubernetes while true sleep 
Shell :: phpcs diferent xml 
Shell :: how to login github in terminal 
Shell :: repository commands 
Shell :: git remove all pdf files 
Shell :: pip install requireents 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =