I'm trying to copy a database from a server (to which I'm connected through ssh) to my localhost. But all that I find is using the copyDatabase()
method which is now deprecated, and the documentation doesn't explain how to do something similar (Or I didn't understand how to)
Also, I'd like to know how can I generalize that to also copy a DB from atlas if it's possible.
CodePudding user response:
If you are using mongodb then its like
step 1: create a tunnel
ssh username@yourdomainOrIP -L 27017:localhost:27017
step 2 :
mongo
use admin
db.copyDatabase(<fromdb>,<todb>,"localhost:27017",<username>,<password>)
CodePudding user response:
- mongodump dump either whole database or a specific collection
- mongorestore restore to your local database