Mongodump from remote server

我怕爱的太早我们不能终老 提交于 2019-11-29 20:48:28

mongo client can parse MongoDB connection string URI, so instead of specifying all connection parameters separately you may pass single connection string URI.

In your case you're trying to pass connection URI as a host, but 127.0.0.1/development is not a valid host name. It means you should specify database parameter separately from the host:

mongodump --host 127.0.0.1 -d development --port 27017 --username user --password pass --out /opt/backup/mongodump-2013-10-07-1


This worked for me.

Reference: https://docs.mongodb.com/manual/reference/program/mongodump


Syntax 1:

mongodump --host <hostname:port> --db <database> --username <username> --password <password> --out <path>

Syntax 2:

mongodump -h <hostname:port> -d <database> -u <username> -p <password> -o <path>



Example 1:

mongodump --host 127.0.0.1:27017 --db db_app --username root --password secret --out /backup/db/app-17-03-07

Example 2:

mongodump -h 127.0.0.1:27017 -d db_app -u root -p secret -o /backup/db/app-17-03-07

You can use with mongodump with --uri

mongodump --uri "mongodb://usersname:password@127.0.0.1:27100/dbname?replicaSet=replica_name&authSource=admin" --out "C:\Umesh"

All your collections will store inside the out folder it will create directory name as your Database name and all the collections are bson and metadata will store as json format.

For restore

mongorestore --uri "mongodb://usersname:password@127.0.0.1:27100/dbname?replicaSet=replica_name&authSource=admin" -d dbname mongodbumppath

Try this it will work.

codewarrior
mongodump --host remotehostip:port --db dbname -u username -p password
abhi12335

Here is an example of exporting collection from node server to local machine:

Host : xxx.xxx.xxx.xx
Port :27017
Username:”XXXX”
Password :”YYYY”
AuthDB : “admin”
“DB”: “mydb”

D:\mongodb-backup>mongodump -h xxx.xxx.xxx.xxx –port 27017 -u “XXXX” -p “YYYY” –authenticationDatabase “admin” –db “mydb”
Ravi Tyagi

You can also use gzip for taking backup of one collection and compressing the backup on the fly

mongodump --db somedb --collection somecollection --out - | gzip > collectiondump.gz

Or with a date in the file name:

mongodump --db somedb --collection somecollection --out - | gzip > dump_`date "+%Y-%m-%d"`.gz
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!