Mongodb Filesystem backup and restore

193 Views Asked by At

I am taking backup of MongoDB filesystem backup(including config files). We are not using sharding in our cluster, having 3node replicaset in place.

Primary Cluster: X_host1, X_host2, X_host3 Secondary Cluster: Y_host1, Y_host2, Y_host3

Taking filesystem backup from X_host1 and restoring it to Y_Host1,2,3 (restoring to diff hostname)

So, how re-configure MongoDB to follow new hostnames? I see the replication nodes are configured into the DB (not any editable config files). Is this the right approach to migrate data from replicated mongodb cluster?

  • Is this the right approach to migrate MongoDB cluster to new hostnames?
  • Is there any way to re-configure new hostnames.
  • AFAIK, after I restore filesystem to new nodes
    • Data is from old nodes, having info about old replica nodes.(X_hosts)
    • How to point it to Y_hosts
1

There are 1 best solutions below

4
On

Follow Restore a Replica Set from MongoDB Backups

In principle do this:

  • Restore the backup on new host (just one)
  • Start the MongoDB as stand-alone, connect to it and drop the local database: db.getSiblingDB('local').dropDatabase()
  • Initiate the ReplicaSet: rs.initiate()
  • Add all members to the ReplicaSet. An initial sync is triggered.

If your database is large, initial sync can take a long time to complete. For large databases, it might be preferable to copy the database files onto each host. For details have a look at linked tutorial.