简体   繁体   中英

How to backup mongodb replica set

I have a mongodb(replica set) and I want to dump this database, I know I can dump a mongodb with a simple cli command and It's working here. But I'm trying to use the same command to dump a replica set, Am I supposed to use the same command?

mongodump -h "example-shard01:27017,example-shard02:27017,example-shard03:27017" --username=myusername --password=mypass --out=/destination

You need to specify the replica set in connection string URI. Similar to this:

"example-shard01:27017,example-shard02:27017,example-shard03:27017/?replicaSet=myRepl"

Your hostnames are bit strange, they look more like a shards in a sharded cluster. Don't mix them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM