taking full backup using mongodump of replicaSet getting failed in failover

34 Views Asked by At

We are currently running on Standalone server on PROD and want to migrate Standalone to ReplicaSet. We are able to migrate it but not able to take backup of replicaSet in below condition.

and so we are currently doing POC on UAT server for that on replicaSet we tried to use below cmd for taking full backup of DB. After fired below cmd we are stopping Primary.. As I will stop Primary backup get stop. does anyone have Ans on this. So using below script once Primary will change mongodump should start taking backup from new Primary server no!

mongodump --host="replSetTST/mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com" --authenticationDatabase admin -u username -p "password" --gzip --out

1

There are 1 best solutions below

0
On

Mongodump uses regular queries and cursors to fetch documents for backup, so it cannot guarantee consistency if there is an election.

Mongodump retrieves documents in natural order without using an index. This is more efficient and faster when fetching all documents in a collection, but the order is not guaranteed to be the same across nodes or even across invitations.

Since the nodes don't share the state of cursors, in order to resume a backup it would have to start a new cursor at the beginning and rescan the collection to make sure nothing is missed. That would not actually be any faster than simply restarting the backup from scratch.

It may be possible to write a client application that would retrieve the documents in a sorted order, which could then resume by resubmitting the same sort with an appropriate query. As far as I know, MongoDB does not provide a product like that.