MongoDB replica set backups & Recovery

Yes, you can take mongodb replica set backup on secondary node. There are different ways to do that, depending on your preferences and requirements. Here are some possible options:
You can use mongodump with --readPreference parameter to specify that you want to dump data from a secondary node. For example:
mongodump --host “/,,” --readPreference “secondary”

This command will connect to the replica set and dump data from the nearest secondary node12. You can also use secondaryPreferred instead of secondary to allow dumping from the primary node if the secondaries are not available2.
You can also use mongodump with --host parameter to explicitly set the secondary host and port. For example:
mongodump --host “” --db “dbname” --archive=“/db_backup/dbname.gz” --gzip

This command will dump data from the specified secondary node and compress the output file3. However, this method requires you to know the address of the secondary node beforehand.
Another option is to restore a replica set from MongoDB backups by copying MongoDB data files directly from one node to another. This method is useful if you want to seed additional members of the replica set with the restored data. The steps are as follows4:
Shut down the mongod instance that you restored.
Copy the primary’s data directory to each secondary.
Restart the mongod instances on the secondary nodes.
Connect to the primary and use rs.reconfig() to update the replica set configuration.